No resource identifier found for attribute 'parentActivityName' in package 'android' - android

I'm trying to complete this tutorial from the Android Page http://developer.android.com/training/basics/firstapp/starting-activity.html But I Eclipse throws this error: "No resource identifier found for attribute 'parentActivityName' in package 'android'" I have included the android-support-library.
Here is the whole AndroidManifest.xml code
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>

android:parentActivityName appears first in Android 4.1 (API level 16). You need to have the latest 4.1 SDK to compile this.

To add to David Wasser's answer, if you use Eclipse and have the correct SDK library installed but still have this error, it means that while the correct library is installed Eclipse does not use it for this project.
To change that, go to your project's Properties (right-click on its name in the Package Explorer and it's the last but one option), select Android in the left hand column and you should have a list called Project Build Target. Then:
Select the appropriate target (Android 4.2.2 or Google APIs for Platform 4.2.2 in this instance)
Save your Manifest file (make a trivial edit if necessary)
Once it is saved Eclipse will process it and those errors should disappear as Eclipse finds the resource identifier in its new build target.

This error will also happen if you don't have the exact version of the SDK that the sample app uses as it's build target. Following the same steps as Julien describes above and choosing an SDK you have locally will fix it.

In IntelliJ IDEA, you need to change in Platform Settings->SDKs->Android something->Build target TO 4.1+.
If you don't see the option, you need an SDK version 4.1 or higher (API level 16+).

Related

android.support.v8 cannot be resolved

I am trying to use renderscript in my Android project. I installed sdk tools 22.6.2 and sdk build tool 19.0.3 and then updated my adt to the latest version. But now I get error that
"The import android.support.v8 cannot be resolved" on the line where I wrote import android.support.v8.renderscript.*. I have also made the following changes in projects.properties
renderscript.target=18
renderscript.support.mode=true
sdk.buildtools=19.0.3
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazing.imazing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.amazing.imazing.MainActivity"
android:label="#string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I am new to Android programming.
I removed all the entries from the project.properties except the one 'target=android-18' and copied the renderscript-v8.jar to the libs folder of my project. I found this jar file in sdk/build-tools/18.1.0/renderscript/lib. I stopped getting that error.
I repeated this process in another project and it works.
Try this
renderscript.target=18
renderscript.support.mode=true
sdk.buildtools=18.1.0
Which IDE are you using? Pay attention to the fact that Android Studio/Gradle-based builds are not yet supported by the RenderScript support library.
In addition, IntelliJ IDEA ignores the project.properties file, even if you are using the default build system ("make").

Conversion to Dalvik format failed with error 1 with android-support-v4.jar

I am trying add the facebook library to my Android project, a getting Conversion to Dalvik format failed with error 1 error. After searching, it seems that my problem is related to the android-support-v4.jar.
Both the jar appears in the facebook dependencies and in the dependencies in my project. I deleted both jars and re-added one to the facebook library, but I still get the error. Below is a screen shot to show where the dependencies are.
Thanks.
You have a duplicated dependency issue.
Remove the last dependency on the NCC project
android-support-v4.jar - /Users/Heather/Documents/workspace/facebook-android-sdk-3.0/facebook/libs
android-support-v4.jar is already provided by the FacebookSDK library project, therefore there's no need to reference it again on the main project
I was having this problem too with an app that used Facebook SDK. I was trying all sorts of stuff, so I'm not sure what exactly fixed but here's settings that worked for me:
FacebookSDK > Properties > Java Build Path > Order and Export
Android 2.2 - NOT CHECKED
Android Private Libraries - CHECKED
Android Dependencies - CHECKED
MyApp > Properties > Java Build Path > Order and Export
Android 4.2.2 - CHECKED
Android Private Libraries - CHECKED
Android Dependencies - CHECKED
In addition, I had done this before, not sure it mattered. Reverted to Facebook SDK version 3.5 from 3.5.2. Updated to latest ADT 22.2.1. Changed Facebook SDK to use Android 2.2 from 4.2.2.
Sometimes the error is caused due to the permissions also. Check if you have declared multiple permissions in your manifest file. Delete the extraneous permission from the file.
This worked for me :
this is a typical manifest file for facebookSDK based app
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.devey.androidnativeapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:permission="android.permission.ACCESS_CHECKIN_PROPERTIES"
android:theme="#style/AppTheme" >
<activity
android:name="com.devey.androidnativeapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/app_id" />
<activity android:name="com.facebook.LoginActivity" >
</activity>
<activity
android:name="com.devey.androidnativeapp.Testnative"
android:label="#string/title_activity_testnative" >
</activity>
</application>
</manifest>
I deleted this extra permission and clean build my app with no further errors :
android:permission="android.permission.ACCESS_CHECKIN_PROPERTIES"

AdActivity not being declared in manifest......but I am using sdk v 3?

There are numerous helpful posts regarding this topic but all require me to use a later sdk than I have written my app for.In an effort to make my app as backwards compatible as possible I chose to create it using Android 1.5 (sdk v 3).
With the code suggested for declaring the manifest I have some issues with eclipse giving me an error as the code refers to later sdk functions not available in Android 1.5
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
/>
Eclipse is telling me that everything after orientation is the problem.
error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').
Can someone please point me in the right direction insofar as code for the manifest or how to compile for a later target?
Cheers!!
Ok.....here is the code from the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ohmywebdesign.trigsolver"
android:versionCode="5"
android:versionName="1.3" >
<uses-sdk android:minSdkVersion="8" />
<uses-sdk android:targetSdkVersion="8" />
<uses-sdk android:maxSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
<meta-data android:value="YOURPUBIDHERE" android:name="ADMOB_PUBLISHER_ID" />
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Something like this:
<uses-sdk android:minSdkVersion="3" />
<uses-sdk android:targetSdkVersion="8" />
<uses-sdk android:maxSdkVersion="15" />
In you manifest will allow you to do what you want.
Also, be sure you have the latest AdMob SDK ie version 4.3.1 http://code.google.com/mobile/ads/download.html
and that you include
<meta-data android:value="YOURPUBIDHERE" android:name="ADMOB_PUBLISHER_ID" />
As MisterSquonk's comment on the question stated, some of the configChanges values were introduced in API levels higher than that of 1.5. Merely changing the values of the minimum/target/maximum API levels in the manifest alone won't solve your issue, you have to make sure to build against an SDK level that declares those values.
For Ant-based builds, this would entail altering the target property's value in project.properties; I don't use Eclipse for my Android projects, so I'm not 100% sure, but here's an excerpt from the Eclipse/ADT documentation that seems relevant to what you'd need to do:
Note: You can change your the Build Target for your project at any time: Right-click the project in the Package Explorer, select Properties, select Android and then check the desired Project Target.
Of course, if you do this, you have to ensure not to directly use any classes/methods from API levels higher than your minimum, or your application will fail at runtime when run on devices implementing lower API levels.
Remember, the manifest is only used at runtime on the device (and by most distribution channels, such as the Android Market). The build target is something completely separate which is used at compile-time.

Why I cannot use attribute installLocation in the Manifest file?

Just a simple XMl file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto"
>
<application android:label="#string/app_name">
<activity android:name=".MyActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Yet, I receive an error
"No resource identifier found for attribute 'installLocation' in
package 'android'"
Why is this happening?
EDIT
It seems that this is an issue with IntelliJ. At least mine. This is the screen of Project Structure. I clicked Android 2.3.3 SDK and changed its build target. I did this after the attribute
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
did not do the trick. Any ideas?
You must specify the android:minSdkVersion and android:targetSdkVersion and compile your APK using, at least, API 8. For instance:
....
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8" />
</manifest>
This will compile the APK using API 8. Handsets running Froyo or above, will be able to use that feature. Eclair and older versions won't (in this case, only Eclair).
The error happens because you are trying to compile the project with an API 7 or older, and installLocation was added on API 8.
Short answer: set your build target to an API level >= 8 and your problem is solved.
Changing the build target is easy:
Right-click the project in the Package Explorer, select Properties, select Android and then check the desired Project Target.
Explanation:
The android:installLocation attribute is available since API level 8, so you'll need to make sure your build target is set to API level 8 or higher, else it will not compile your application.
android:minSdkVersion can be less than 8 and your application will still work on older devices, but devices with API level < 8 will simply ignore the attribute.

Running the Android emulator

I am trying to run the emulator and each time I tried it it gives me the same error message 'Application stopped unexpectedly' I tried sorting it by killing the adb process in the task manager. The log cat error says:
WARNING: Application does not specify an API level requirement!
Device API version is 7 (Android 2.1-update1)
I do not know how this could be sorted, or if there is any other issue.
Please help, thanks!
Amrita
I guess the solution for your problem is:
In your manifest there should be something like this
<uses-sdk android:minSdkVersion="int" />
Now just change the number to the desired version number. Additionally you should also change the value of the target in the default.properties file.
AdnroidManifest.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jaxx.progressbarexample"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
**<uses-sdk android:minSdkVersion="9" />**
</manifest>
One more thing to remind,you specify the min sdk version in your AndroidManifest.xml file similar to what your emulator target sdk version which you specify while creating your AVD.or create a new AVD with a target sdk of your application
.

Categories

Resources