When I run
gradle lint
From project dir or root dir I get whole bunch of reports (for every Activity and Application) like
<issue
id="MissingRegistered"
severity="Error"
message="Class referenced in the manifest, com.mypackage.activities.MyActivity, was not found in the project or the libraries"
category="Correctness"
priority="8"
summary="Ensures that classes referenced in the manifest are present in the project or libraries"
explanation="If a class is referenced in the manifest, it must also exist in the project (or in one of the libraries included by the project. This check helps uncover typos in registration names, or attempts to rename or move classes without updating the manifest file properly."
url="http://developer.android.com/guide/topics/manifest/manifest-intro.html"
urls="http://developer.android.com/guide/topics/manifest/manifest-intro.html"
errorLine1=" <activity"
errorLine2=" ^">
<location
file="AndroidManifest.xml"
line="58"
column="9"/>
</issue>
I'm sure they are referenced correctly because after a build like
gradle build
or
gradle assembleDebug
Every Activity can be launched.
My projects have some subprojects if that matters.
settings.gradle
include ':Lib1'
include ':Lib2'
include ':MainProject'
Every activity is listed in manifest of MainProject and is located in MainProject.
MainProject/AndroidManifest.xml
Packagename and activity names were replaced, but the general package hierarchy represents the real hierarchy. Also I removed some activities and left two for example. All others are in the same package and defined just like the last one, just have different names.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.package"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="19" />
<application
android:name="com.my.package.subpackage.MyApp"
android:allowBackup="true"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:largeHeap="true"
android:hardwareAccelerated="true"
android:theme="#style/AppTheme" >
<activity
android:name="com.my.package.subpackage.activities.SplashActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="sensorLandscape"
android:configChanges="orientation|screenSize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.my.package.subpackage.activities.HelpActivity"
android:theme="#style/TransparentTheme"/>
</application>
</manifest>
As stated in tech doc Gradle don't support lint yet. Before Gradle will be stable you can be faced with many problems
Related
I am getting the error "Tag attribute package has invalid character ' '." in the Android Manifest, while there is no obviously invalid character. Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exampl e.harounsmida.test2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="com.example.harounsmida.test2.app.AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.harounsmida.test2.LoginActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.harounsmida.test2.RegisterActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan" />
<activity
android:name="com.example.harounsmida.test2.MainActivity"
android:label="#string/app_name"
android:launchMode="singleTop" />
<activity
android:name="com.example.harounsmida.test2.UploadToServerActivity"
android:label="#string/app_name"
android:launchMode="singleTop" />
</application>
</manifest>
I don't understand where is the problem, Android Studio says that "File under the build folder are generated and should not be edited." although I didn't edit it.
Remove space from package name :
package="com.exampl e.harounsmida.test2"
After removing space :
package="com.example.harounsmida.test2"
For those who still can't solve this problem :
1 - Close Android Studio.
2 - Browse to your project directory.
3 - Rename the project directory name to something else.
4 - Open Android Studio and open your project (browse to the renamed directory) .
5 - Select Build --> Edit Flavors --> Type something like yourname.myapplication in application id textbox (avoid using non English characters or space)
Image
6 - Select Build --> Rebuild Project and you are good to go.
Please consider gradle file and see what you have given as applicationId, any name that you have given in applicationId will be copied from gradle file and pasted to manifest
Also see for space and extra character in package's value
Try this code
package="com.example.harounsmida.test2"
remove the space in your package definition because space is not allowed
After throwing the error as mentioned above, Android Studio opens the file "debug\AndroidManifest.xml". Note that the Manifest file for the project is "main\AndroidManifest.xml". I didn't notice initially and was removing the space from the former file (which Android Studio opens up).
Hope it helps!
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").
I am following he tutorial from this site: http://developer.android.com/training/basics/firstapp/creating-project.html, but when I run the default program in eclipse when an android project is created, it gives me the error R could not be found. To fix this, I commented out the lines with R and ran it again, but now it gives me the error: Could not find MyFirstApp.apk!... I have tried all other solutions on this site, but none of them work. If anybody knows how to fix this, please let me know!
here is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<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="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.myfirstapp.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>
</manifest>
When your .R class could not be found, there is an error in your project - commenting out the lines with the .R class does not fix the problem.
Perhaps you just have to clean your workspace (Project > Clean...) or delete the bin and gen folder in your project, they should be rebuilt automatically.
Look at the Problems tab next to the Console tab where you get the errors and take a look at the messages.
when I had originally installed the android sdk it installed to some folder in my filesystem. I moved the SDK manager to a folder on my desktop, and installed updates through there. I had to change my android path to that folder, and everything fixed! Thanks for your help though, it was much appreciated.
I have an project, build with Gradle in Android Studio v 0.3.2.
My project has dependencies to two other modules(android library). The project structure is well defined with build.gradle files.
The problem is... when i run the project on an Android device, i get installed 3 apk's on my device. One is the main project(the only right one) and the other two are from the imported modules(theese two i don't want to get installed).
How can i achieve this? Or what i'm doing wrong?
Project Structure:
MyLibModule
MainProject
MainProject->libraries->MyOtherModule
Where MyLibModule is at the same path as the Main project, because i also need this module in a other project.
Just to be clear: The whole project build's OK, all dependencies are OK, but why do i get 3 APK's on my device?
After a whole day struggling with this problem, i located the cause of this strange behaviour. The problem was the manifest of library module. Before i switched to Android studio i used Eclipse. And i had a testActivity declared in the manifest of the library project. Removing all test activities from the manifest's of my library modules solved the problem. Now Android Studio installs only the MainProject apk.
Some code:
The manifest of MyLibModule:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.mylibmodule"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7"/>
<application>
<activity
android:name=".TestActivity"
android:label="#string/app_name">
</activity>
</application>
</manifest>
Changed to:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.mylibmodule"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7"/>
<application>
</application>
</manifest>
....And the same for MyOtherModule.
NOTE: the empty application node must stay in the manifest, to avoid build errors.
remove the intent-filter from your library's launch activity
<application>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Changed to
<application>
<activity android:name=".MainActivity"/>
</application>
It's because your libraries are defined in their build.gradle files as being applications instead of libraries. Look for this line:
apply plugin: 'android'
and replace it with:
apply plugin: 'android-library'
You may need to make other adjustments to the buildfile as well because not everything that applies to applications can be specified in a library buildfile. See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-projects for more information.
I have tried nearly everything to get the R.java file to reappear and nothing has worked yet. The src folder and the AndroidManifest.xml file both have an error icons next to them.
I get the following error from the Manifest file...
"error: No resource identifier found for attribute 'installLocation' in package 'android'"
I get the following errors from some .java files in the src folder...
"R cannot be resolved to a variable"
In these .java files the "R" is underlined with a red squiggle.
I have tried the following and none of these methods have worked...
Cleaning & Rebuilding the project
Removing the "import Android.R" statement
Renaming the project and changing it in the Manifest file
Checking to ensure that the res/drawable files are lowercase
Check that my package declaration in your AndroidManifest.xml matches package name
Restarting Eclipse
Ticking Android Version Checkbox in the Java Build Path
Installing the correct SDK Platform
Any suggestions??
EDIT:
Here's the manifest file...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.jfedor.frozenbubbleupdate"
android:installLocation="preferExternal"
android:versionCode="8"
android:versionName="1.7" >
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-sdk android:minSdkVersion="2" />
<application
android:icon="#drawable/app_frozen_bubble"
android:label="#string/app_name" >
<activity
android:name="org.jfedor.frozenbubbleupdate.FrozenBubble"
android:alwaysRetainTaskState="true"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name"
android:launchMode="singleInstance" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="org.jfedor.frozenbubble.GAME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
What value do you have in the minSDK in your AndroidManifest?
This problem can be due to having a sdk version lower than API 8:
http://developer.android.com/guide/topics/data/install-location.html.
Also, if you could post your Manifest would be usefull. Your R file is not being generated because some error in your project, in your Manifest from what you said.
You will need something like this:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
You should add android:targetSdkVersion="17" to your <uses-sdk> tag. The target SDK should always be set to the highest SDK version currently available.
As the android:installLocation attribute wasn't introduced until API version 8, it is likely that not specifying the target SDK is causing the compiler to compile against the wrong API version.