Building app with library module cannot find AndroidManifest.xml - android

I want to build an Android App with AndroidAnnotations.
Here is a simplified version on GitHub which fails to build/pre-process: https://github.com/aiQon/androidannotationsexample
The app is composed of a main app module and a library module.
Both use AndroidAnnotations (AA). The lib module has a workaround to find the AndroidManifest.xml in debug builds (it refers to the release manifest, because gradle does not build the debug variant for libs).
However, the manifest is found for the library module but not for the main app.
The gradle file of the main app is:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "de.stelle_beratung.androidannotationslibraryexample"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apt {
arguments {
androidManifestFile variant.outputs.processResources.manifestFile
resourcePackageName android.defaultConfig.applicationId
}
}
dependencies {
compile project(":mylibrary")
apt "org.androidannotations:androidannotations:3.2+"
compile 'org.androidannotations:androidannotations-api:3.2+'
}
Gradle complains with:
http://pastebin.com/QZtnHcZD
Could someone please point me in the right direction on how to build this simplified project to have a controller Bean in the lib module and reference it successfully in the main app activity by using AA?
I appreciate any help.

Since android gradle plugin 14.4, the following line does not work anymore:
variant.outputs.processResources.manifestFile orvariant.processResources.manifestFile
You have to use this one instead:
variant.outputs[0].processResources.manifestFile
Please note if you have multiple outputs (when using splits), you may want to use another output (other index than zero).

Ok I got it. Was using Android Studio from the Canary Channel. Going back to Beta solved the issue because I could use android gradle plugin 0.12.2. This solved everything.

Related

How to use module as library in android

I am going to use cognalys (third party library) in my app for mobile verification..I cloned that from git hub and i imported that cognalys in my app as module.How to use that module as library in my project(how to convert that as library)..I dont know how to use that..By using that only i can create a class for mobile verification of user...
Please help me to find out the solution
This is my build.gradle of cognalys project
apply plugin: 'com.android.library'
android {
compileSdkVersion 10
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
}
First add the library project as module.
File->New->Import module
then add this line to your dependencies in gradle
compile project(':yourmodule')

Android Studio Error:(3, 0) Plugin with id 'com.android.application' not found

I'm new to android studio and had somebody write an app I made which was originally used in app inventor. I followed his template and added new things. The app has a problem with the Gradle and gives me the following.
"Error:(3, 0) Plugin with id 'com.android.application' not found."
It also says that my extras Android Support Repository isn't installed however it is. and everything is up to date. I saw many things about updating the Gradle, How do I do that if the SDK manager didn't.
code is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "contactorganizer.introcode.or.myapplication"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
}
Sorry about not having much knowledge.
If you would like the project I can email it to you because I have absolutely no clue and would love to just build this.
Thanks for your help!
When I updated my Android Studio to the latest, I got the same problem. Here is how I solved it.
First:
Add the following code to the top of your build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Second: Find the gradle-wrapper.properties.
Change the last sentence to this:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Hope this works for you.
I have faced the problem too. The android plugin is 1.2.3. It appears when running one module task in the module directory like this way, ../graldew :module:xxx.
I eventually notice plugin 1.2.3 cannot get right context and android plugin 1.5 works well. So It will work to give it right gradle file.
../gradlew -b ../build.gradle -c ../settings.gradle :module:xxx
This is the situation for me. You can just regard it as a reference.

Getting Android Studio, Gradle and Android Annotations working together

now that i've decided to use Android Annotations with Android Studio i wanted to implement it through Gradle. After some thoughtful research i've found out that there are older and newer ways of implementing Android Annotations through Gradle depending on which version android studio, gradle or android annotations have. i came to this useful tutorial -> http://www.jayway.com/2014/02/21/androidannotations-setup-in-android-studio/ , and tried to implement this , at first, with the new 'android-L' as target SDK like
targetSDKversion "android-L" + compileSdkVersion 20 + buildToolsVersion "20.0.0"
until i tried it with
targetSDKversion 20 + compileSdkVersion 20 + buildToolsVersion "20.0.0"
and also
targetSDKversion 19 + compileSdkVersion 19 + buildToolsVersion "19.1.0".
Everytime i was getting 2 warnings that my java classes dont seem to get precompiled. even though it seems that it pre-creates the build/generated/source/apt directory. but without my pre-processed class from my MainActivity -> MainActivity_
I always do get following Warnings:
Note: Resolve log file to D:\AndroidProjects\GradleTest\app\build\generated\source\apt\androidannotations.log
Note: Initialize AndroidAnnotations 3.0.1 with options >{androidManifestFile=D:\AndroidProjects\GradleTest\app\build\intermediates\manifests\debug\AndroidManifest.xml, resourcePackageName=at.gradle.defuex.gradletest}
warning: Unclosed files for the types '[dummy1407928544078]'; these types will not undergo annotation processing
warning: The following options were not recognized by any processor: '[androidManifestFile, resourcePackageName]'
My build.gradle file looks like this:
buildscript{
repositories{
mavenCentral()
}
dependencies{
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
}
}
repositories{
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "at.gradle.defuex.gradletest"
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
signingConfigs{
releaseConfig{
storeFile file("gradlekeystore.jks");
storePassword ("*************");
keyAlias "keyAlias";
keyPassword "*************";
}
}
buildTypes {
release {
runProguard false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseConfig
}
debug {
debuggable true
applicationIdSuffix ".debug"
}
}
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName "at.gradle.defuex.gradletest"
}
}
dependencies {
apt "org.androidannotations:androidannotations:3.0+"
compile "org.androidannotations:androidannotations-api:3.0+"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Im using following Versions:
Android Studio version 0.8.2
Gradle version 0.12.2
android-apt version 1.3
android annotations version 3.0.1 (as seen in the build.gradle file)
If there should be a solution to this problem please tell me, because im confused now.
If there should be a better annotations framework or a way of using cool annotations, please tell me that too.
And if it should not be a common way anymore to use annotations for android projects anyway, please pleeeeease tell me that too.
,but i would prefer a solution to my problem :)
Cheers!
Try to run gradlew clean build from project root.
Then try to make project (button with a green arrow with 0 and 1) before running on a device. Should be fine.

Can i setup Robolectric in its own module

Is is possible to setup robolectric in its own module and add it as a dependency to my project? I can add it to my project module fine but id prefer if it was in its own module. Ive created a javaLibrary module and added the following code to the gradle build script
buildscript {
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
//Prior to AS 0.5.9: classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.9.+'
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.0'
//previous plugin >> classpath 'com.novoda.gradle:robolectric-plugin:0.0.1-SNAPSHOT'
}
}
allprojects {
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
}
apply plugin: 'android'
apply plugin: 'android-test' //previously >> apply plugin: 'robolectric'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.irishtimes.newsapp.tests"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
androidTest.setRoot('src/tests') //note that this is androidTest instead of instrumentTest
}
}
dependencies {
androidTestCompile 'junit:junit:4.10'
//include the stable robolectric 2.3 library
androidTestCompile 'org.robolectric:robolectric:2.3'
androidTestCompile 'com.squareup:fest-android:1.0.+'
}
//only include files that are suffixed with Test.class and set the max heap size
androidTest {
include '**/*Test.class'
maxHeapSize = "2048m"
}
Ive also added a blank manifest file and a dummy test in a src/tests/java. In my previous setup when i run ./gradlew test, my tests would run and id get feedback. Now when i run the same command my build script runs but it does not pick up my tests at all. If anyone has any reference to tutorials or advice or a quick solution that would be great. Thanks!
Yes its possible with a different plugin. Plugin supported by robolectric do not support this.
Plugin can be found here https://github.com/novoda/gradle-android-test-plugin
A ready to use example can be found here https://github.com/nenick/android-gradle-template
If you want to run tests from a separate folder, but not necessarily a separate module, I have had some success with the Android Studio Unit Test Plugin along with this gradle plugin.

error: package xxx does not exist . how do include packages in the build correctly?

I'm trying to use the project android-wheel from https://code.google.com/p/android-wheel/
with Android Studio.
I imported them as modules and put the dependency for 'wheel' into the build.gradle of 'wheeldemo'.
when building it with gradle it shows errors, that packages do not exist, even though the imports in the java file don't show any errors:
I'm not sure, what I'm missing here. Might be something obvious, since I'm not to familiar with android programming, yet.
edit: here is the build.gradle of the wheeldemo module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'kankan.wheel.demo'
minSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile project(':wheel')
}
Make sure the build.gradle of "wheel" has correct plugin type. It should be 'android-library' instead of 'com.android.application'.

Categories

Resources