I'm using this library to add Transition Effects to ViewPager. Since it is a library project, I've imported it as a module in Android Studio and then I added it to my project as a dependency. But now, when I try to run my project, Android Studio builds and runs the library project instead of my app, which's completely different from mine. But, when I run the same project using Eclipse, it runs perfectly and my app works as usual. I've no idea why this's happening.
Here's the build.gradle file of my main module -
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 8
targetSdkVersion 14
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:gridlayout-v7:19.0.1'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile project(':comjfeinsteinjazzyviewpagerMainActivity')
}
Here's the build.gradle file of the library project -
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
packageName 'com.jfeinstein.jazzyviewpager'
minSdkVersion 8
targetSdkVersion 14
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_5
targetCompatibility JavaVersion.VERSION_1_5
}
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile files('libs/nineoldandroids-2.4.0.jar')
compile 'com.android.support:support-v4:19.0.1'
}
settings.gardle -
include ':launcher'
include ':lib'
Launch Configurations -
Related
I had a project library in android studio with following dependencies.
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])//Local binary dependency
implementation 'com.android.support:appcompat-v7:26.1.0'//Remote binary dependency
api group: 'com.google.collections', name: 'google-collections', version: '1.0'
My question is how to build a jar/aar with dependencies?
I have tried many ways but it did not including "google-collections" dependency in exported jar/aar?
how can I do that?
Thanks.
I have two modules app and library. I have MusicMainActivity class in app module and Notification service class in library module.Now I want to call MusicMainActivity from a service class. I tried this by using
Intent in-new Intent(this,packagename.MusicMainActivity.class);
and also
Intent in-new Intent(this,MusicMainActivity.class);
But this show an error on MusicMainactivity.
Error:(326, 48) error: cannot find symbol class MusicMainActivity
Error:Execution failed for task ':library:compileReleaseJavaWithJavac'.
Compilation failed; see the compiler error output for details.
library module gradle file
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
}
}
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.0'
compile files('libs/aacdecoder-android-0.8.jar')
}
app moudle gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.adio"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile 'com.google.firebase:firebase-messaging:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
You need to add the app module as a dependency to the library module. You can do this by manually editing the build.gradle file of the library module, adding the line
compile project(':app')
Or you can use the Module Settings dialog in Android Studio.
Alternatively, you can configure an intent filter which would allow you to start your activity without explicitly using its class name in the library module. See Intents and Intent Filters for more details. This choice is actually preferable because it is much more flexible.
Why is Android Studio 1.5.1 (stable) auto-updating my app.iml file to use alpha support libraries?
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "my.app.id"
minSdkVersion 15
targetSdkVersion 22
versionCode 5
versionName "1.0.4"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url 'https://github.com/8tory/parse-android-sdk.m2/raw/master/' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1'
compile 'com.android.support:support-v4:22.1'
compile 'com.android.support:recyclerview-v7:22.1'
}
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.
I'm wanting use this github project: https://github.com/makovkastar/FloatingActionButton in my android app, however I dont know if I have to download the project and move to libraries package, or if I have only do this:
dependencies {
compile 'com.melnykov:floatingactionbutton:1.1.0'
}
You need search the file build.gradle of your whole app folder.
There should be 2 of them, open the file under app folder you will see some like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
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:21.0.2'
compile 'com.melnykov:floatingactionbutton:1.1.0'
}
Put compile 'com.melnykov:floatingactionbutton:1.1.0' in dependencies
You don't need to download the source code if just want to use the library.
Just add line compile 'com.melnykov:floatingactionbutton:1.1.0' to dependencies section in build.gradle