Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Weather App (2015) Concurrency and Error Handling Making Our Code Asynchronous

Kyle Baker
Kyle Baker
8,211 Points

Unfortunately, stormy has stopped

//Below is my error message

java.lang.SecurityException: Permission denied (missing INTERNET permission?)

//Looked up online and StackExchange suggested
<uses-permission android:name="android.permission.INTERNET" />

//I tried this and it still doesn't work

<?xml version="1.0" encoding="utf-8"?> <manifest package="kybacorps.com.stormy" xmlns:android="http://schemas.android.com/apk/res/android">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            //ADDED CODE BELOW
            <uses-permission android:name="android.permission.INTERNET" />
           //END OF ADDED CODE
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

</manifest>

//Any help would be dandy, I'll admit to not knowing much about permissions so it could an //easy fix (fingers crossed)

2 Answers

Seth Kroger
Seth Kroger
56,413 Points

The uses permission tag need to be higher up, usually right after the opening manifest tag. The tags are nested much like HTML or a layout XML file. Nesting permission inside the activity doesn't work because it should belong to the entire application, not just a single screen of it.

<?xml version="1.0" encoding="utf-8"?> <manifest package="kybacorps.com.stormy" xmlns:android="http://schemas.android.com/apk/res/android">

 //PLACE ADDED CODE HERE
 <uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

</manifest>
Kyle Baker
Kyle Baker
8,211 Points

thanks Seth Kroger. the app is working it seems but it doesn't look like Ben's app (that gps looking interface). I do have the "09-22 21:36:22.253 21808-21808/kybacorps.com.stormy D/MainActivity: Main UI code is running!" now so am I good?

Kyle Baker
Kyle Baker
8,211 Points

actually, that's probably just a menu that comes with that phone emulator