Migrating to Gradle Plugin 3.0 - android

I am migrating our project to the Gradle 3.0 plugin, I am going error by error a I am new in Gradle.
Now, I am facing this issue:
Error:Could not determine the dependencies of task ':ComponentsLib:mergeProdReleaseResources'.
> Could not resolve all task dependencies for configuration ':ComponentsLib:prodReleaseRuntimeClasspath'.
> Could not resolve project :Datastore.
Required by:
project :ComponentsLib
> Project :ComponentsLib declares a dependency from configuration 'releaseCompile' to configuration 'prodRelease' which is not declared in the descriptor for project :Datastore.
Here is the gradle.build for ComponentLib module:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
flavorDimensions "default"
publishNonDefault true
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
}
}
productFlavors {
internal {
minSdkVersion rootProject.ext.debugMinSdkVersion
}
prod {
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "2g"
}
lintOptions {
quiet false
warningsAsErrors true
abortOnError true
checkReleaseBuilds false
textReport = true
htmlReport = false
xmlReport = false
ignore(rootProject.ext.lintIgnore as String[])
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
debugCompile project(path: ':Datastore', configuration: 'internalDebug')
releaseCompile project(path: ':Datastore', configuration: 'prodRelease')
}
And here is the gradle.build for Datastore module:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
flavorDimensions "default"
publishNonDefault true
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
}
}
productFlavors {
internal {
minSdkVersion rootProject.ext.debugMinSdkVersion
}
prod {
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "2g"
}
lintOptions {
quiet false
warningsAsErrors true
abortOnError true
checkReleaseBuilds false
textReport = true
htmlReport = false
xmlReport = false
ignore(rootProject.ext.lintIgnore as String[])
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
debugCompile project(path: ':Core', configuration: 'internalDebug')
releaseCompile project(path: ':Core', configuration: 'prodRelease')
}
The modules are build in order -> ':Core', ':Datastore', ':ComponentsLib', ':Push',....
Any idea what is happening here?
Thanks.

I finally fixed it.
Porblem was that I had to rewrite
debugCompile project(path: ':Datastore', configuration: 'internalDebug')
releaseCompile project(path: ':Datastore', configuration: 'prodRelease')
to
instalation project(':Datastore')
because the new Gradle 3.0 plugin manages build process in the different way.

Related

Room Persistence inside of Lib

I am looking for a good way to import Room Persistence inside of my Lib to export .aar . I have the following issue that .aar cannot handle dependencies.
When I export my arr and import into another project as lib, it seems as it has no scope to room.
my lib Gradle file :
apply plugin: 'com.android.library'
apply plugin: 'maven'
archivesBaseName = '*****'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 5
versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Write out the current schema of Room
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
deployerJars
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'android.arch.persistence.room:runtime:1.1.0-beta3'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.0-beta3'
}
Thanks.

Compiling Android Project

What is wrong? I can't compile project and get error:
Error:Execution failed for task ':app:transformClassesWithDexForGoogleDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --force-jumbo --num-threads=4 --multi-dex --main-dex-list C:\Users\andre\Desktop\MYproject\app\build\intermediates\multi-dex\google\debug\maindexlist.txt --output C:\Users\andre\Desktop\MYproject\app\build\intermediates\transforms\dex\google\debug\folders\1000\1f\main C:\Users\andre\Desktop\MYproject\app\build\intermediates\transforms\jarMerging\google\debug\jars\1\1f\combined.jar}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.gvarani.myproject"
minSdkVersion 17
targetSdkVersion 26
versionCode 15
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true //important
}
useLibrary 'org.apache.http.legacy'
signingConfigs {
release
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard/proguard-project.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
flavorDimensions "release"
productFlavors {
google {
dimension "release"
}
other {
dimension "release"
}
}
dexOptions {
javaMaxHeapSize "2g"
jumboMode true
}
}
ext {
supportLibVersion = '26.0.0'
gmsVersion = '11.0.4'
}
dependencies {
googleCompile "com.google.firebase:firebase-crash:${gmsVersion}"
googleCompile "com.google.firebase:firebase-messaging:${gmsVersion}"
googleCompile "com.google.firebase:firebase-auth:${gmsVersion}"
googleCompile 'com.anjlab.android.iab.v3:library:1.0.42'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:customtabs:${supportLibVersion}"
compile "com.google.firebase:firebase-perf:${gmsVersion}"
compile "com.google.firebase:firebase-database:${gmsVersion}"
compile "com.google.firebase:firebase-ads:${gmsVersion}"
compile 'com.firebaseui:firebase-ui-auth:2.2.0'
compile 'com.firebaseui:firebase-ui-database:2.2.0'
compile 'com.google.code.gson:gson:2.8.1'
compile 'dev.dworks.libs:volleyplus:0.1.4'
compile 'cat.ereza:customactivityoncrash:2.1.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
compile 'org.fabiomsr:moneytextview:1.1.0'
compile 'com.zsoltsafrany:needle:1.0.0'
compile 'com.github.lykmapipo:local-burst:v0.2.0'
compile 'com.github.javiersantos:AppUpdater:2.6.1'
compile 'de.psdev.licensesdialog:licensesdialog:1.8.2'
compile 'org.jsoup:jsoup:1.10.3'
compile 'com.wordplat:ikvStockChart:0.1.5'
compile 'com.android.support:multidex:1.0.0'
//Kotlin dependencies
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services
Please try below code
android{
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
//...
compile 'com.android.support:multidex:1.0.0'
}
**Hope this will help **
Put below line in build.gradle;
multiDexEnabled true
like this:
defaultConfig
{
applicationId "yourProjectPackage"
minSdkVersion 15
versionCode 1
versionName "1.0"
targetSdkVersion 23
multiDexEnabled true //important
}
add follow code in your manifest.xml file:
<application
android:name="android.support.multidex.MultiDexApplication">
</application>
Add below lines to your app build.gradle
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Add maven { url "https://maven.google.com" } in Project level gradle
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. not solving

I have possibly tried all the solutions regarding this issue.
The full error is: Error:Execution failed for task "
':app:transformClassesWithDexForDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
"
I am posting my build.gradle scripts:
Script name: RajawaliCardBoardExample-master
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
name: Module:app >>
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
incremental true
javaMaxHeapSize "4g"
jumboMode = true
}
defaultConfig {
applicationId "com.eje_c.rajawalicardboard"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':rajawalicardboard')
compile project(':lib_panorama_max')
compile 'com.android.support:multidex:1.0.1'
}
name: Module:lib_panorama_max >>
apply plugin: 'java'
task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') {
destinationDir file("$buildDir/native-libs")
baseName 'native-libs'
extension 'jar'
from fileTree(dir: 'libs', include: '**/*.so')
into 'lib/'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
options.encoding = "UTF-8"
options.debug = true
options.debugOptions.debugLevel = "source,lines,vars"
options.encoding = "UTF-8"
}
dependencies {
compile files('libs/commons-httpclient-3.1.jar')
compile files('libs/android.jar')
compile fileTree(dir: 'build/native-libs', include: ['*.jar'])
}
name: Module:Rajawali >>
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
name: Module:rajawalicardboard >>
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':rajawali')
}
Please help to sort it out! :(
At first you should add
defaultConfig
{
// Enabling multidex support.
multiDexEnabled true
}
Open Module:app .You missing multiDexEnabled true in here .
defaultConfig {
applicationId "com.eje_c.rajawalicardboard"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
Read Official Document about MultiDex
The option 1 was adding multiDexEnabled true
But you told it didn't work at all, you can try excluding group group: 'com.android.support', module: 'multidex' now which means in the compilation for example change
compile project(':rajawalicardboard')
To
compile project(':rajawalicardboard'){
exclude group: 'com.android.support', module: 'multidex'
}
Don't only try on this, do the same in compile project(':lib_panorama_max') if only the changes above didn't work. Try removing compile 'com.android.support:multidex:1.0.1' too.

Plugin not found when importing project as library in Android Studio

I am trying to integrate an application to another one. To do that I compiled the first one as a library and after that I added it to the dependencies of the application project after I added it as a module following some guides in stackoverflow.
The problem is that after doing that, I got an error about a missing plugin. Although I have researched a bit over google I have had no luck on that one.
The error is Error:(4, 0) Plugin with id 'com.google.protobuf' not found.
Open File
Both applications work very well, each on their own... What am I doing wrong ?
Here is my build graddle of the main app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.arlind.myapplication"
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
Here is the build graddle of the added library
import java.text.SimpleDateFormat
apply plugin: 'com.android.library'
apply plugin: 'com.google.protobuf'
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3'
}
}
android {
signingConfigs {
global {
keyAlias "Lind"
keyPassword "gators"
storeFile file("lindkey.keystore")
storePassword "gators"
}
}
compileSdkVersion 22
buildToolsVersion "23.0.0"
android {
lintOptions {
abortOnError false
}
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.global
}
}
productFlavors {
catapult {
versionCode getLongDate().toInteger()
versionName '12.1-' + getShortDate()
}
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '18.0'
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
compile project(path: ':wallpaperPicker')
}
sourceSets {
main {
manifest.srcFile '../AndroidManifest.xml'
java.srcDirs = ['../src', '../util', '../extra/src']
res.srcDirs = ['../res', '../extra/res']
proto {
srcDir '../protos'
}
}
}
}
def getDate(String dateFormat) {
def df = new SimpleDateFormat(dateFormat)
Calendar c = Calendar.getInstance();
TimeZone tz = c.getTimeZone();
df.setTimeZone(tz)
return df.format(new Date())
}
def getLongDate() {
return getDate("yyMMddHH")
}
def getShortDate() {
return getDate("yyMMdd")
}

Gradle DSL method not found: 'applicationId()'

I am getting this error on building the application in Android Studio.
Gradle DSL method not found: 'applicationId()'
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
applicationId "com.ms.knowursensor.android"
minSdkVersion 13
defaultConfig {
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "sensorgraph"
stl "c++_static"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk {
debuggable = true
}
}
debug {
debuggable true
jniDebuggable true
}
}
sourceSets {
main {
jniLibs.srcDir 'src/main/jniLibs'
// use the jni .so compiled from the manual ndk-build command
jni.srcDirs = [] //disable automatic ndk-build
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
This issue came when i recently update the SDK. How to resolve this issue?
Move applicationId and minSdkVersion into your defaultConfig closure.

Categories

Resources