Supplied String module notation 'libs/dagger-1.2.2.jar' is invalid - android

I'm trying to get Mobile GTS' prebuilt Candy Jump app to run and build an APK in Android Studio. I've followed this video precisely: https://www.youtube.com/watch?v=YpYVdJVYWg0.
However, I am using Gradle 4.7, JDK 1.8.0, Android Plugin Version 3.1.2 and Build Tools Version 27.0.3. I'm not sure if that would have anything to do with why I can't get it to build, but I've had error after error and I've kind of boiled it down to what I hope is the last error.
Supplied String module notation 'libs/dagger-1.2.2.jar' is invalid. Example notations: 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'.
How can I fix this error?
Here's my build.gradle (module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "net.mobilegts.candyjump"
minSdkVersion 19
targetSdkVersion 27
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
productFlavors {
}
}
dependencies {
implementation('com.google.android.gms:play-services:+') { exclude module: 'support-v4' }
implementation 'libs/dagger-1.2.2.jar'
implementation 'libs/javax.inject-1.jar'
implementation 'libs/nineoldandroids-2.4.0.jar'
implementation 'libs/support-v4-19.0.1.jar'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:support-core-utils:27.1.1'
}

You should use "implementation files" for jar files. Try the following code:
implementation files('libs/dagger-1.2.2.jar')
implementation files('libs/javax.inject-1.jar')
implementation files('libs/nineoldandroids-2.4.0.jar')
implementation files('libs/support-v4-19.0.1.jar')

Related

issue converting project to FCM

Having successfully converted one project to FCM, I'm running into problems converting my second. This project is unique as I prefer to keep it on targetSdkVersion 22.
This is my gradle file . . .
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:22'
defaultConfig {
applicationId "com.myname.myapp"
minSdkVersion 21
targetSdkVersion 22
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
implementation project(':library')
implementation project(':googleplayservices_lib')
implementation files('libs/gson-2.2.2.jar')
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.android.support:support-v4:22.2.1'
}
apply plugin: 'com.google.gms.google-services'
When I try to run the project on an emulator I get . . .
Program type already present:
com.google.android.gms.common.data.Freezable
I have no idea what this is about and google turns up nothing useful. However it appears to be caused by the firebase-core dependency because it I remove that, the project runs fine.
What might be causing this?

Data binding cannot be added to my project

In my Android project, I have needed to enable the dataBinding library in module level build.gradle as below, but it gives me the error in the image. How can resolve it?
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "com.nasser.studio.multipledeletelistview"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding{
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.codesgood:justifiedtextview:1.0.2'
}
Edit 1.
I've changed the project level build.gradle to add support-v4 library, but now it throws the following error:
repositories {
google()
jcenter()
configurations.all {
resolutionStrategy.force "com.android.support:support-v4:27.0.2"
}
}
one of your 3rd party libraries or sdk you use rely on support version 21.0.3. Either remove it or have resolutionStrategy in your Gradle.
configurations.all {
resolutionStrategy {
force ....
}
}
Try upgrade your android gradle plugin.
Add compile "com.android.support:support-v4:27.0.2" manually to your gradle file.
That should solve your problem.
That's not a Databinding error, It's just saying that all your support-related libraries should use the same version. For example look at my gradle file:
implementation "com.android.support:recyclerview-v7:$libraries.googleSupportVersion"
implementation "com.android.support:appcompat-v7:$libraries.googleSupportVersion"
implementation "com.android.support:support-v13:$libraries.googleSupportVersion"
implementation "com.android.support:design:$libraries.googleSupportVersion"
implementation "com.android.support:cardview-v7:$libraries.googleSupportVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
My support library version being:
ext.libraries = [
...
googleSupportVersion : '27.1.1',
...
]
Your issue seems to be that compile 'com.codesgood:justifiedtextview:1.0.2' internally is using the support library with a version different than yours. However your version is totally updated I wouldn't downgrade it just to have it match with the other, in any case you could just add a:
allprojects {
configurations.all {
resolutionStrategy.force "com.android.support:support-v4:27.0.2"
}
}
In your project gradle. You could also run gradlew app:dependencies in the Android Studio console, do a Ctrl+F on the output, search for that com.android.support:support-v4:27.0.2 and figure out from where is coming. (You only have one dependency for what I see, so there's not much science from where IT should be coming)
Let me know if this works for you.

How to fix NDK build error in AndroidStudio

I want build my project from AndroidStudio into my phone, but when run button in Android Studio. show me this error :
Error:Execution failed for task ':app:compileDebugNdk'.
> Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental.
Build.Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 14
targetSdkVersion 23
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
How can i fix it?
paste below code in your build.gradle(Module:app)
sourceSets {
main {
jni.srcDirs = []
}
}
buildTypes{
}
Paste this in build.gradle above buildTypes{}
sourceSets {
main {
jni.srcDirs = []
}
}
buildTypes{
}

Android Studio - Build variation & Module selection

I'm building an application which needs a library with 2 variants - simulator & actual.
My objective is to create build tasks say assembleSimulatorDebug & assembleDebug.
assembleSimulatorDebug will include simulator module/library and assembleDebug will include actual module to build the apk.
I'm thinking of having if else blocks in dependencies sections of build.gradle. Can I have something like this?
I'm very new to gradle and trying from yesterday to set up something like this. It will be v helpful if anyone can provide some hints or links where I can get an idea to achieve this.
Update:
Found another solution. It's in another my answer.
It is possible by usage of 'Flavor products' of android gradle plugin. You can split library implementation by product flavor.
Initial requirements 'com.android.tools.build:gradle:1.0.0', Android Studio 1.0.1.
I created project at GitHub, so you'll be able to get it, run and learn.
You need to create two flavors of your app and library, too. For example, normal and simulator
Application's build.gradle
apply plugin: 'com.android.application'
android {
lintOptions {
abortOnError false
}
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.tivogi.gradle"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
normal {
}
simulator {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
normalCompile project(path: ':library', configuration: 'normalRelease')
simulatorCompile project(path: ':library', configuration: 'simulatorRelease')
}
Library's build.gradle
apply plugin: 'com.android.library'
android {
publishNonDefault true
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
normal {
}
simulator {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
Library:
split implementation between flavors by productFlavors (see my sample project if will have questions about that);
add publishNonDefault true into its build.gradle
From Gradle Plugin User Guide
It is also possible to publish all variants of a library. We are planning to allow this while using a normal project-to-project dependency (like shown above), but this is not possible right now due to limitations in Gradle (we are working toward fixing those as well).
Publishing of all variants are not enabled by default.
To enable them:
android {
publishNonDefault true
}
Application:
add normal and simulator product flavors (productFlavors);
add next lines to dependencies section
normalCompile project(path: ':library', configuration: 'normalRelease')
simulatorCompile project(path: ':library', configuration: 'simulatorRelease')
From Gradle Plugin User Guide
To create a dependency on another published artifact, you need to specify which one to use:
dependencies {
flavor1Compile project(path: ':lib1', configuration: 'flavor1Release')
flavor2Compile project(path: ':lib1', configuration: 'flavor2Release')
}
After all of that you'll be able to build 2 variants of applicaiton: normal and simulator.
Found solution for 2 libraries, it looks simpler. It's based on next from official guide
Finally, like Build Types, Product Flavors can have their own dependencies. For instance, if the flavors are used to generate a ads-based app and a paid app, one of the flavors could have a dependency on an Ads SDK, while the other does not.
dependencies {
flavor1Compile "..."
}
So you can create 2 individual libraries and create 2 flavors, for example, libraries are library-normal and library-simulator and flavors are normal and simulator.
Application build.gradle
apply plugin: 'com.android.application'
android {
lintOptions {
abortOnError false
}
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.tivogi.gradle"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
normal {
}
simulator {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
normalCompile project(":library-normal")
simulatorCompile project(":library-simulator")
}
Application:
add only those lines into dependencies;
normalCompile project(":library-normal")
simulatorCompile project(":library-simulator")
Library:
does not require any change;
I published sample project of this solution at individual-libraries branch.

"provided" scope not working - android studio with gradle

I need to prevent gradle from exporting a certain shared library.
I´ve read that using the provided scope should do the trick, but it seems that it was only working with older gradle versions.
Is there any other way to exclude dependencies from the build process to not get them into the final apk?
I have found solution here: https://stackoverflow.com/a/10406184/310760
But for Gradle 2.0 it has small changes:
configurations{
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
test {
compileClasspath += configurations.provided
}
}
sourceSets.main.compileClasspath += configurations.provided
idea {
module{
scopes.PROVIDED.plus += [configurations.provided] // for Gradle 2.0
}
}
I have the same problem, and I found some solutions.But I don't understand.
http://www.sinking.in/blog/provided-scope-in-gradle/
Solved thie problem by using the android-apt gradle plugin.
see https://bitbucket.org/hvisser/android-apt/overview
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "org.ligboy.test.card.module1"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
apt
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt 'com.android.support:support-v4:21.+'
apt 'com.google.code.gson:gson:2.2.+'
apt 'com.android.support:cardview-v7:+'
apt 'com.android.support:recyclerview-v7:+'
}
Fought with this for a while and found:
"provided" is part of gradle 1.3.0, but doesn't work properly.
"provided" works properly in gradle 1.5.0!
FYI: I had to delete my build directory after upgrading to 1.5.0 to remove the lib file from the .aar.

Categories

Resources