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.
Related
Ok so I was going through a tutorial online, then when i tried to change my build.gradle file to compileSdkVersion 21 instead of 23 everything lost the plot and now all my previous projects etc are all showing errors.
In the AndroidManifest.xml the 2 http lines and all the android: are all red and the the activity opening tag has a red squiggly line under it also. I have zero idea what i have done wrong! Almost like internet has gone? Just a noob so i have no idea please help!
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/tools"
package="com.site.project" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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>
</manifest>
This answer extends #adelphus'.
A new app\build\intermediates\manifests\full\debug\AndroidManifest.xml would have listed these errors. Close and reopen the AndroidManifest.xml file from the project pane under app > manifests.
Hope this works for you.
You have duplicate schema definitions for the xmlns:android namespace in your manifest file - only one schema per namespace is allowed and I suspect the compiler is getting confused by the duplicate entry.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/tools"
package="com.site.project" >
should be:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.site.project" >
The namespace schema definitions are important - they are used to define attribute prefixes. Because your duplicate entry is invalidating the android namespace, all attributes prefixed with android: will be wrong - this is why all the android: attributes have an error (red line) displayed.
Alternatively, just remove the tools namespace completely if you're not using any attributes with the tools: prefix in your manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.site.project" >
you need download jdk here "https://www.oracle.com/technetwork/java/javase/downloads/index.html"
then go to File > Project Structure > here you config path jdk default C:\Program Files\Java\jdk-11.0.2 . Hope this works for you
I think you have two AndroidManifest.xml files to change it. Just rename the debug AndroidManifest.xml and that solution works for me.
Search for the AndroidManifest.xml file(s). on the project ParentPath. if there are multiple, keep one and delete the others.(usually find many other)
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").
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
I got an ClassNotFoundException with a static broadcastreceiver. The exception is fired when installing the app via eclipse on the device. I am developing an sony smartwatch extension, so I need to use the "SmartExtensionUtils" project from the sony sdk. As long as I was working inside the code example project everything was fine. I started a new project with Maven + Android and now it is no longer working!!! No idea why?!? I reckon something with the packages went wrong....
I got the following error:
E/AndroidRuntime(11201): java.lang.RuntimeException: Unable to instantiate receiver com.bla.move.smartwatch.sony.ExtensionReceiver: java.lang.ClassNotFoundException: com.bla.move.smartwatch.sony.ExtensionReceiver
My broadcastreceiver class is called ExtensionReceiver. The name inside the manifest file is the same ...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bla.move.smartwatch.sony"
android:versionName="1.0" android:versionCode="1">
<uses-sdk android:minSdkVersion="7"/>
<uses-permission
android:name="com.sonyericsson.extras.liveware.aef.EXTENSION_PERMISSION" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name="SmartWatchPreferenceActivity" android:label="#string/preference_activity_title">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<service android:name=".SmartWatchExtensionService" />
<receiver android:name=".ExtensionReceiver">
<intent-filter>
.....
</intent-filter>
</receiver>
....
What could be the problem? Any suggestions??? I did alreday clean + rebuild (a couple of times)!
Did you include the SmartExtensionAPI and SmartExtensionUtil projects as dependencies, both in your project and in Maven?
Try cleaning the workspace (start Eclipse with the -clean flag), and make sure your project's JDK compliance settings is set to 1.6 (not 1.7)! That worked for me. I set the JDK compliance level of the whole workspace, instead of the project itself, and the error just disappeared!
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"