Android library dependencies - java

I'm doing an android library project.
The library project has compile some 3rd party library such as Volley.
When user use the library, user need to compile the volley too. If user do not compile, the app of user will not find the volley code.
But I don't want to the user compile volley library, just compile my library. Is there a solution to solve???
There is my library gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
consumerProguardFiles 'proguard-rules.pro'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.squareup:seismic:1.0.1'
compile 'com.android.volley:volley:1.0.0'
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.android.support:recyclerview-v7:23.0.1"
compile "com.android.support:support-v4:23.0.1"
compile "com.android.support:support-annotations:23.0.1"
compile "com.android.support:design:23.0.1"
}
There is a sample app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 108
versionName "3.1"
}
signingConfigs {
debug {
storeFile file("debug.jks")
storePassword 'develop'
keyAlias "develop"
keyPassword "develop"
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.debug
}
}
lintOptions {
disable 'MissingTranslation'
abortOnError false
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
}
dependencies {
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'org.jsoup:jsoup:1.10.2'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.soundcloud.android:android-crop:1.0.1#aar'
compile 'com.getkeepsafe.taptargetview:taptargetview:1.8.0'
compile 'com.squareup:seismic:1.0.1'<<<<<<<<<<<<<<<<<<<< I need to hide this
compile 'com.android.volley:volley:1.0.0'<<<<<<<<<<<<<<< I need to hide this
compile project(':mylibrary')
}

Related

I am facing gradle sync error when I open the project

ERROR: Unable to find method
'org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V'.
I tried to upgrade and downgrade the Gradle but getting the same error
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.micutu.locatedriver"
minSdkVersion 14
targetSdkVersion 24
versionCode 7
versionName "1.6"
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'io.nlopez.smartlocation:library:3.2.5'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.google.android.gms:play-services-places:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
compile 'com.google.code.gson:gson:2.3'
}

gradle proj sync failed, every methods tried

error message:
Error:Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File<br>Show Details
This error is along with tons of similar dependencies errors.
methods tried:
clear caches
reinstall android studio
download the latest Gradle and replace the original one.
4. Play with the build.gradle file and add several lines
I am just a student who wants to start some android project with java.
Thanks in advance.
Here's my up-level gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
here's my gradle file for my proj:
apply plugin: 'com.android.application'
repositories {
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
jcenter()
google()
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.2" // -------------------> Add this
defaultConfig {
applicationId "com.example.alexs.applicationone"
minSdkVersion 21
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'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support.test.espresso:espresso-core:3.0.2-alpha1'
}
my sdk version is 27 btw.
Add buildToolsVersion "26.0.2" to build.gradle file like below :
android {
compileSdkVersion 26
buildToolsVersion "26.0.2" // -------------------> Add this
defaultConfig {
applicationId "com.example.alexs.applicationone"
minSdkVersion 21
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'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
In your top-level build.gradle file, not the app module one you posted, add the following block:
allprojects {
repositories {
google()
}
}
Or in your app/build.gradle file (the one you posted) add the google repository:
repositories {
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
jcenter()
google()
}

can't find referenced method boolean isInstantApp() in library class android.content.pm.PackageManager

I am getting two error while generating signed apk in android studio 3.
when i try to build it build successfully.
Please help how to resolve this error.
but when i try generate signed apk i get following errors.
Warning:com.google.android.gms.internal.zzbga: can't find referenced method 'boolean isInstantApp()' in library class android.content.pm.PackageManager
Warning:com.google.android.gms.internal.zzbgb: can't find referenced method 'boolean isInstantApp(java.lang.String)' in library class android.content.pm.PackageManager
following is my build.gradle file code.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.micropeda.sudoku"
minSdkVersion 15
targetSdkVersion 22
versionCode 20171216
versionName "2.4.1"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:11.6.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.instantapps:instantapps:1.1.0'
}
Resolved my self, i just update build.gradle file.
Here is my updated build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.1'
defaultConfig {
applicationId "com.micropeda.sudoku"
minSdkVersion 15
targetSdkVersion 26
versionCode 20171216
versionName "2.4.1"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:11.6.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.instantapps:instantapps:1.1.0'
}

Android studio plain java library proguard

Is it possible to have different build types for plain java libraries in Android Studio with gradle? My intention is to run proguard and minify the jar file size.
Java build.gradle
apply plugin: 'java'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
}
Android build.gradle
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "test.app"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
productFlavors {
buildWithSingleAlarmFlavour {
applicationId "test.app"
versionName ".1"
}
buildWithMultipleAlarmFlavour {
applicationId "test.app"
versionName "0.1"
}
}
}

Coverage report says zero coverage on android with gradle

I've been unable to get code coverage to work on any of my android projects.
To simplify things I created a new project (selected empty activity).
Added a new utility class to the the project in src/main/java.
I then created a unit test for it in src/androidTest/java.
Updated the gradle file to enable coverage.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.michaelkrussel.coverageapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
jacoco {
version "0.7.1.201405082137"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
I ran the tests then using ./gradlew createDebugCoverageReport. The unit test shows that the test I created passed, but the coverage report reports zero coverage.
I assume I'm either missing something in the gradle file or not running the correct gradle task, but I cannot figure out what.
I'm using this configuration in my project and work fine!
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "br.com.acs.app"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
testApplicationId "br.com.acs.app.test"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
androidTestCompile 'junit:junit:4.11'
androidTestCompile('com.android.support.test:testing-support-lib:0.1') {
exclude group: 'junit'
}
}

Categories

Resources