I have two modules in my project:
app
app_list
Both modules have java and res. app_list has some activities that I want to launch in app.
In Eclipse, I had app_list as dependency library and I was able to launch activity of app_list. In Android Studio, when I added app_list as dependency, it says:
"Error:A problem occurred configuring project ':app'.
> Dependency NewMathBuzz:app_list:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: <home>/NewMathBuzz/app_list/build/outputs/apk/app_list-release-unsigned.apk
"
app > build.gradle is as below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.mass.mathbuzz"
minSdkVersion 7
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':app_list')
compile fileTree(dir: 'libs', include: ['*.jar'])
}
app_list > build.gradle is as below:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.android.support:appcompat-v7:22.0.0'
}
Could someone help me with this?
Everything was fine,
basically when I changed app_list.gradle as
apply plugin: 'com.android.application' to apply plugin: 'com.android.library' and deleted applicationId from app_list.gradle
it compiled and generated apk but I was getting runtime error that was because both app and app_list both had same resource main_activity so R.java didn't have main_activity res of app_list so it was giving illegal_parameter error . When I changed name of main_activity to some unique name it solved the issue
Related
I have recently update Android Studio to Android Studio 2.1.2. I have stuck with a strange error. Error is printed below. This happens when I just create new android studio project.
Gradle 'myapp' project refresh failed
Error:No toolchains found in the NDK toolchains folder for ABI with prefix: aarch64-linux-android
Note : I am using java8 and the module gradle.build file looks like below. Since I have just created the project I have not added any NDK related files.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
When I Create A New Project in Android Studio , Show this Error And i Can't Create EditText And Plain TextView.
Project Structure PIC
How I Resolve This Problem ?
My Gradel Build :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.mr_enginner.first_project_run"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
Make sure put the java version in the project settings. "Project structure" in File menu.
I have a problem with applying a new library dependancy in Project struction.
on the lesson to learn how to use google map,
Project Structure -> Module -> app -> dependancy -> library dependancy
I faced
a NoClassDefFoundError : Could not initialize classcom.android.tools.idea.structure.gradle.MavenDependencyLookupDialog
Any suggestion or feedback will be appreciated
Thank you.
my build.gradle is like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "org.googlemap.googlemapdemo"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'}
Error:(1, 0) Gradle DSL method not found: 'android()'
Possible causes:
The project 'MyApp1' may be using a version of Gradle that does not contain the method.
Gradle settingsThe build file may be missing a Gradle plugin.
Apply Gradle plugin
Root/build.gradle
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
applicationId "com.example.shark.gpsapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
}
App/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.example.shark.myapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
I coudln't open any of my old projects.Please do suggest a answer.
I got this error after android studio update.
You cannot call android until after you apply the android plugin com.android.tools.build:gradle.
The gradle build file uses a DSL based on Groovy, a Java-like dynamic language. android { ... } is a call to a method named android, passing the block. The message you are getting indicates that the method android has not been defined. It is defined in the plugin.
Somehow, your root level build.gradle file is a near duplicate of your app level build.gradle. It should not be so.
I suggest that you create a completely new project, using Android Studio, and copy it's root level build.grade file to the existing project.
My project have two modules:
App
Facebook-lib
Here are my gradle files:
setting.gradle
include ':app', ':facebook-lib'
Module App gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.test"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile project (':facebook-lib')
}
Module Facebook-lib gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
}
Whenver I am trying to access Facebook-lib class in App module. It works but I can't do vice versa.
I get com.app.testpackage doesn't exist or cannot find symbol class.
What I am doing wrong here?
You can't achieve it.
Your Module App has a dependency with the Module Facebook library. It means that you can use the classes inside the library in your main module.
Your Facebook library doesn't have a dependency with your module. It means that you can't use the classes in main module.
Also you can't create a circular dependency.