I need to convert an android-studio application project to library project. For this, I have followed official documentation from https://developer.android.com/studio/projects/android-library#Convert
I.e. changed
apply plugin: 'com.android.application'
to
apply plugin: 'com.android.library'
After that, it's giving "Module not specified" error in run configuration setting. I have tried syncing gradle files, invalidating and restarting android-studio, but "Module not specified" error has not been resolved.
How to resolve this error in converting application project to library project?
It is because a library module cannot run as app.
You need to new a module(say newapp) and set its buuild.gradle apply plugin: 'com.android.application', then edit the root settings.gradle include 'newapp'.
Give it a go.
Generate the aar file by running directly the gradle build task, selecting it from the gradle tasks of the app module:
Related
I am following the AWS docs, here. I am able to add everything into my project's build.gradle, AndroidManifest.xml, and app's build.gradle EXCEPT for the apply plugin. When I add:
apply plugin: 'com.amazonaws.appsync'
I get the following error:
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.amazonaws.appsync']
How do I fix this? When I remove the apply plugin from the app's build.gradle, then my app works again.
Did you try updating you gradle version and is your android studio also in the latest state, follow this thread and also update your question with the project's build.gradle file
https://stackoverflow.com/a/37091489/1503130
I am new to Kotlin and Dokka;
Following wikis and tutorials I've tried to setup my project for dokka documentation tool with the following lines in gradle build files:
In project gradle file:
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.15"
In module gradle file:
apply plugin: 'org.jetbrains.dokka-android'
Android studio version is 2.3.3
After Sync, project rebuild and Android studio restart I expected a dokka task appear in "Tools"/"Task & Contexts"/"+ Open Task" but I can't see any.
What am I missing/doing wrong?
Thank you in advance
The dokka task should appear in the Gradle tasks list, check the Gradle panel that's on the right by default:
I wanted to try instant-run from AS 2.0 - for this to work I had to update to build-plugin to 2.0.0-alpha6 - but when doing this I cannot gradle-sync the project anymore as I am getting:
Gradle 'myProject' project refresh failed
Error:Cause: com.android.sdklib.repository.FullRevision
Anyone knows the reason/workaround for this?
I use JakeWharton/sdk-manager-plugin.
build-plugin to 1.5.0 is not problem.
In my project I have added
apply plugin: 'android-sdk-manager'
I removed it from the gradle file of App & it worked.
Hope will help you.
In my case I had to mark out 'apply plugin: 'android-sdk-manager' from the project's 'build.gradle' file. Obviously, environment and project's configurations vary, however, marking it out and allowing
dependencies{
.....
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10+'
}
handle the plugin resolved this issue.
Is there any way or workarounds or just hints to make plugins from gradle and gradle-experimental working together?
For example to mix those two versions:
com.android.tools.build:gradle:1.3.1
com.android.tools.build:gradle-experimental:0.3.0-alpha4
I have an existing project which uses some external plugins (app/build.gradle):
apply plugin: 'com.android.model.application'
apply plugin: 'com.android.databinding'
apply plugin: 'com.jakewharton.hugo'
in my root build.gradle I have:
com.android.tools.build:gradle-experimental:0.3.0-alpha4
Issues which I have:
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.databinding']
> java.lang.NullPointerException (no error message)
or
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.jakewharton.hugo']
> 'android' or 'android-library' plugin required.
Without other plugins my project works fine (I have Android Library with some NDK code which is called from my main project. Problem occurs when I add mentioned plugins on any others.
And the question is - is it a gradle-experimental issue or issue of each plugin (hugo, databinding, apt, probably much more).
Or maybe you have any hints if there is any other way to have app with current stable gradle plugin and library (with NDK code) which uses gradle-experimental?
What I want to avoid is a dealing with *.mk files and (as full as possible) Android Studio support. Bigger picture is to prepare .aar library with NDK code (just simple computation) which will be able to plug in to existing projects.
I've been able to mix gradle stable and -experimental android plugins without any issues by using recent versions in my project.
You should be able to define both dependencies inside your project's build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.3.0-alpha7'
classpath 'com.android.tools.build:gradle:1.4.0-beta6'
}
and then either use apply com.android.(application|library) or com.android.model.(application|library) from your various module's build.gradle files.
Haven't used experimental plugin yet, but I guess, you can divide your project into 2 Gradle modules and use standard Android Gradle Plugin for the application module and new experimental plugin in the NDK module.
#ph0b is right, I am just giving an update of that answer.
you will need in your gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
and in your project build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath "com.android.tools.build:gradle-experimental:0.7.3"
}
I have an Android project in IntelliJ IDEA. It consists of two modules: app and library. App depends on library and library depends on app (Yes, it's not good, but I have what I have and can't change this). IDEA in project settings warn me about circular dependencies, but project builds correctly. Project structure looks like this:
project
|__app
| |__src
| |__build.gradle
|__libarary
| |__src
| |__build.gradle
|__build.gradle
|__settings.gradle
Now I'm trying to migrate to new Android build system based on Gradle and have a trouble here. In my build.gradle from app module I add dependency on library
compile project(":library")
Also I tryed to add dependency in library on app like
compile project(":app")
But gets error from build system, when gradle trys to assemble library module:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> Module version project:app:unspecified depends on libraries but is not a library itself
What I can do with this without changing project structure
This parameters have changed.
You should now refactor:
In the library project use:
apply plugin: 'com.android.library'
In the app project use:
apply plugin: 'com.android.application'
In the library project use:
apply plugin: 'android-library'
In the app project use:
apply plugin: 'android'
Make sure you have the newest Android tools:
classpath 'com.android.tools.build:gradle:0.5.+'
If you arrive here searching for the same error with Android 3.0 you should know the current workaround is:
downgrade to kotlinVersion = '1.1.2-2'
and disable incremental build in gradle.properties kotlin.incremental=false
The issue is planned for the next alpha https://issuetracker.google.com/issues/38447344