Dear team:
what is happening there? I have a working Android Studio 2.3 project that builds
- an AAR library (with mix of Java and C programs) and
- an APK application with the main program(s)
going to Android Studio 3.4 I only see hundreds of lines of trace where Gradle just throws meaningless exceptions;
i.e., you are not even getting some meaningful error messages!
here the build.gradle from project 2.3:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
// Used to build applicationId “net.wavvox.voxdigits”
classpath ‘com.android.tools.build:gradle:2.3.3’
// Used to build moduleName “wavvox-decoder”
classpath ‘com.android.tools.build:gradle-experimental:0.9.3’
}
}allprojects {
repositories {
jcenter()
maven { url “https://jitpack.io” }
}
}
and project 3.4:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
// Used to build applicationId “net.wavvox.voxdigits”
classpath ‘com.android.tools.build:gradle:3.4.1’
// Used to build moduleName “wavvox-decoder”
classpath ‘com.android.tools.build:gradle-experimental:0.11.1’
}
}allprojects {
repositories {
google()
jcenter()
maven { url “https://jitpack.io” }
//mavenCentral()
}
}
(the app/build.gradle and the wavvoxlibrary/build.gradle below)
All I get is at project level (VoxDigits13_SDK):
com/android/builder/Version
Open File
Run build the list of thrown exceptions:
‘C:\Users\jm\StudioProjects\VoxDigits13_SDK\wavvoxlibrary\build.gradle’ line: 5
A problem occurred evaluating project ‘:wavvoxlibrary’.
at org.gradle.initialization.exception.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:99)
at org.gradle.initialization.exception.DefaultExceptionAnalyser.collectFailures(DefaultExceptionAnalyser.java:55)
at org.gradle.initialization.exception.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
at org.gradle.initialization.exception.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:29)
at org.gradle.initialization.DefaultGradleLauncher.finishBuild(DefaultGradleLauncher.java:174)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:165)
at org.gradle.initialization.DefaultGradleLauncher.getConfiguredBuild(DefaultGradleLauncher.java:129)
at org.gradle.internal.invocation.GradleBuildController$2.execute(GradleBuildController.java:67)
at org.gradle.internal.invocation.GradleBuildController$2.execute(GradleBuildController.java:64)
at org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:82)
at org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:75)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:183)
at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:75)
at org.gradle.internal.invocation.GradleBuildController.configure(GradleBuildController.java:64)
at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner.run(ClientProvidedBuildActionRunner.java:57)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:58)
at
… … …at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:143)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
at org.gradle.api.Script$apply.callCurrent(Unknown Source)
at build_6i1o2dpe7dm2dlglljc6ctmws.run(C:\Users\jm\StudioProjects\VoxDigits13_SDK\wavvoxlibrary\build.gradle:5)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
… 120 more
ditto Configure build:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ‘:wavvoxlibrary’.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:72)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$600(LifecycleProjectEvaluator.java:53)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:108)
at org.gradle.internal.Factories$1.create(Factories.java:25)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:183)
at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:226)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:220)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:186)
at
… … …at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:38)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:37)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:26)
at
… … …at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating project ‘:wavvoxlibrary’.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:206)
at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:211)
at org.gradle.configuration.BuildOperationScriptPlugin$1$1.run(BuildOperationScriptPlugin.java:69)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.configuration.BuildOperationScriptPlugin$1.execute(BuildOperationScriptPlugin.java:66)
at org.gradle.configuration.BuildOperationScriptPlugin$1.execute(BuildOperationScriptPlugin.java:63)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:48)
at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:63)
at org.gradle.configuration.project.BuildScriptProcessor$1.run(BuildScriptProcessor.java:44)
at org.gradle.internal.Factories$1.create(Factories.java:25)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:200)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:186)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:41)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:106)
… 102 more
Caused by: java.lang.NoClassDefFoundError: com/android/builder/Version
at com.android.build.gradle.model.LibraryComponentModelPlugin.apply(LibraryComponentModelPlugin.java:54)
at com.android.build.gradle.model.LibraryComponentModelPlugin.apply(LibraryComponentModelPlugin.java:49)
at
… … …at build_6i1o2dpe7dm2dlglljc6ctmws.run(C:\Users\jm\StudioProjects\VoxDigits13_SDK\wavvoxlibrary\build.gradle:5)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
… 123 more
Why do I get this?
here the app/build.gradle (Android Studio 2.3)
import java.text.DateFormat
import java.text.SimpleDateFormatbuildscript {
repositories {
mavenCentral()
}
dependencies {
classpath ‘com.jakewharton.hugo:hugo-plugin:1.2.1’// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }
}
apply plugin: ‘com.android.application’
apply plugin: ‘hugo’// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file(“keystore.properties”)// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))// We use the place values to calculate the veresion code from the major/minor/patch version numbers
ext.PLACE_VALUE_MAJOR = 100 * 100;
ext.PLACE_VALUE_MINOR = 100;
ext.PLACE_VALUE_PATCH = 1;// >>>>> Set the version code here <<<<<
ext.majorVersion = “12”;
ext.minorVersion = “05”;
ext.patchVersion = “72”
ext.majorVersionVoxChat = “01”;
ext.minorVersionVoxChat = “06”;
ext.patchVersionVoxChat = “32”;/** Base name for VoxChat APK file /
ext.ApkBaseVoxChat = “VoxChat”
/* Base name for VoxDigits APK file */
ext.ApkBaseVoxDigits = “VoxDigits12”/**
- Custom name for the VoxChat APK that includes the version name and the Git commit hash
- @return the name of the VoxChat APK file
*/
private String apkNameVoxChat() {
return ext.ApkBaseVoxChat + apkSuffix(versionNameVoxChat());
}/**
- Custom name for the VoxDigits APK that includes the version name and the Git commit hash
- @return the name of the VoxDigits APK file
*/
private String apkNameVoxDigits() {
return ext.ApkBaseVoxDigits + apkSuffix(versionNameVoxDigits());
}/**
- The name of the app version, using the Semantic Versioning format (major.minor.patch)
- @return
*/
String versionNameVoxChat() {
return versionName(ext.majorVersionVoxChat, ext.minorVersionVoxChat, ext.patchVersionVoxChat);
}/**
- The name of the app version, using the Semantic Versioning format (major.minor.patch)
- @return
*/
String versionNameVoxDigits() {
return versionName(ext.majorVersion, ext.minorVersion, ext.patchVersion);
}/**
- The name of the app version, using the Semantic Versioning format (major.minor.patch)
- @param majorVersion
- @param minorVersion
- @param patchVersion
- @return
*/
static String versionName(majorVersion, minorVersion, patchVersion) {
return removeLeadingZeros(majorVersion) + “.”
+ removeLeadingZeros(minorVersion) + “.”
+ removeLeadingZeros(patchVersion);
}/**
- Remove leading zeros from a String of digits.
- TODO: trap for invalid {@code # value} parameter
- @param value an integer expressed as a String
- @return
*/
static String removeLeadingZeros(value) {
return new Integer(value).toString();
}/**
- Generates the version code of VoxDigits
- @return
*/
Integer versionCodeVoxDigits() {
return versionCode(ext.majorVersion, ext.minorVersion, ext.patchVersion);
}/**
- Generates the version code of VoxDigits
- @return
*/
Integer versionCodeVoxChat() {
return versionCode(ext.majorVersionVoxChat, ext.minorVersion, ext.patchVersion);
}/**
- The version code of the app. This is used by the Google Play Store to decide which versions to
- offer to users, so we should exercise care if we change this method. This blog has some scheme
- suggestions for apps with NDK libs: {@Gradle | Android By Code}
- TODO: handle leading zeros correctly; it’s ok right now because ext.majorVersion = “10”
- @param majorVersion
- @param minorVersion
- @param patchVersion
- @return
*/
Integer versionCode(majorVersion, minorVersion, patchVersion) {
int versionCode
= (Integer.valueOf(majorVersion) * ext.PLACE_VALUE_MAJOR)
+ (Integer.valueOf(minorVersion) * ext.PLACE_VALUE_MINOR)
+ (Integer.valueOf(patchVersion) * ext.PLACE_VALUE_PATCH);
System.out.println(" ************************************************“);
System.out.println(” *** appVersionCode() " + " – versionCode: " + versionCode + " ***“);
System.out.println(” ************************************************");
return versionCode;
}/**
- Generate the suffix to append to the APK file name to indicate build version and commit hash, if available
- @param versionName
- @return
/
static String apkSuffix(String versionName) { // jm20190405
def commitHash = getShortCommitHash()
if (‘unknown’ != commitHash) {
return “-” + versionName + “_” + commitHash
} else {
return “-” + versionName
}
}/**
- Get the short commit hash of the current Git head. This definitively tells us which version has
- been built.
- @return
/
static String getShortCommitHash() { // jm20190405
def osName = System.getProperty(“os.name”);
def gitPathAsText
if (osName.toLowerCase().contains(“windows”)) {
gitPathAsText = “where git”.execute().getText()
} else {
gitPathAsText = “which git”.execute().getText()
}
System.out.println("getShortCommitHash() " + "\n\t – osName: " + osName + " – gitPathAsText: " + gitPathAsText);
String gitRev = ‘unknown’
if (gitPathAsText) {
def shortHeadHash = “git rev-parse --short head”.execute().getText()
gitRev = shortHeadHash.trim()
}
return gitRev;
}/**
- Today’s date in ISO 8601 format
- @return
*/
static String todayIso8601() {
Date now = new Date()
DateFormat nowDateFmt = new SimpleDateFormat(‘yyyy-MM-dd’)
return nowDateFmt.format(now);
}android {
compileSdkVersion 28 // jm*20190405
buildToolsVersion “25.0.3”defaultConfig { minSdkVersion 16 /*** was: 9, then: 14 ***/ targetSdkVersion 28 /*** was: 21, then: 25 ***/ buildConfigField "String", "BUILD_DATE", "\"" + todayIso8601() + "\"" buildConfigField "String", "SHORT_COMMIT_HASH", "\"" + getShortCommitHash() + "\"" } signingConfigs { create("myConfig") { storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeType "jks" } } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig = signingConfigs.myConfig } } productFlavors { voxDigits { applicationId "net.wavvox.voxdigits12" versionCode versionCodeVoxDigits() versionName versionNameVoxDigits() } voxChat { applicationId "net.wavvox.voxchat" versionCode versionCodeVoxChat() versionName versionNameVoxChat() } // Rename APK for the appropriate productFlavor applicationVariants.all { variant -> variant.outputs.every { output -> String flavorName = variant.productFlavors[0].name System.out.println("flavorName: " + flavorName); switch (flavorName) { // jm*20190405 case "voxChat": output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace("app-voxChat", apkNameVoxChat())); break; case "voxDigits": default: output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace("app-voxDigits", apkNameVoxDigits())); break; } // switch } } } // End productFlavors block
}
dependencies {
/** WavvoxLibrary AAR module */
compile project(path: ‘:wavvoxlibrary’)/** Google Android support libraries */ compile 'com.android.support:support-annotations:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:design:25.3.1' /** Dagger 2 */ compile 'com.google.dagger:dagger:2.10' annotationProcessor 'com.google.dagger:dagger-compiler:2.10' provided 'javax.annotation:jsr250-api:1.0' /** Progress Circle */ compile 'com.github.jakob-grabner:Circle-Progress-View:v1.3'
}
and the wavvoxlibrary/build.gradle (Android Studio 2.3)
import java.text.SimpleDateFormat
apply plugin: ‘com.android.model.library’
/**
Set the version code here <<<<<
- Each subversion code should be exactly 2 numeric digits or we will get wrong versions published
- in the Google Play Store
*/
ext.majorVersion = “03”;
ext.minorVersion = “07”;
ext.patchVersion = “090”;/**
- The name of the app version, using the Semantic Versioning format (major.minor.patch)
- @return
*/
String appVersionName() {
return removeLeadingZeros(ext.majorVersion) + “.” + removeLeadingZeros(ext.minorVersion) + “.” + removeLeadingZeros(ext.patchVersion);
}/**
- The name of the app version, using a combination of stripped and non-stripped leading zeros in
- the major and minor version numbers, and omitting the patch version number. We surround the text
- with double quotes for use as a build config field so we don’t get a field type mismatch
- @return
*/
String versionNameWavvoxFormat() {
return “"” +removeLeadingZeros(ext.majorVersion) + “.” + ext.minorVersion + “"”;
}static String removeLeadingZeros(value) { // jm*20190405
return new Integer(value).toString();
}/**
- The version code of the app. This is used by the Google Play Store to decide which versions to
- offer to users, so we should exercise care if we change this method. This blog has some scheme
- suggestions for apps with NDK libs: {#link Gradle | Android By Code}
- @return
*/
String appVersionCode() {
return ext.majorVersion + ext.minorVersion + ext.patchVersion;
}model {
android {
compileSdkVersion 25
buildToolsVersion “25.0.3”defaultConfig { minSdkVersion.apiLevel 16 /*** was: 8 ***/ targetSdkVersion.apiLevel 25 //versionCode appVersionCode() versionName appVersionName() setProperty("archivesBaseName", "wavvoxlibrary-$versionName") buildConfigFields { create() { type "String" name "VERSION_NAME_WAVVOX_FORMAT" value versionNameWavvoxFormat() } } testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } // defaultConfig buildTypes { release { minifyEnabled true proguardFiles.add(file("proguard-rules.pro")) } } // buildTypes // } // android // jm*20190405 // android.ndk { // jm*20190405 ndk { moduleName "wavvox-decoder" platformVersion = 16 // vs. 21 for 64bit? // full optimization, char data type is signed CFlags.addAll([ // "-I${project.rootDir}/app/src/main/jni".toString(), // jm*20190405 "-Iwavvoxlibrary/src/main/jni".toString(), "-O3",
// “-fsigned-char”
“-Wno-error=format-security”,
“-std=c99”, // as before; vs. -c11 ?
// “-mfloat-abi=softfp”,
“-mfpu=neon”,
// “-march=arm64”, // how to build 64bit?
“-fvisibility=hidden”,
“-g”
])// Loads NDK libraries: log, android; we may need to add OpenSLES in the future (for native audio) ldLibs.addAll([ "log" , "android"
// , “OpenSLES”
])// these platforms cover 99% percent of all Android devices abiFilters.addAll([ "armeabi-v7a" , "arm64-v8a"
// , “x86”
// , “x86_64”
])
} // ndk// C source files to include in the build script // android.sources.main.jni { // jm*20190405 sources { main { jni { source { include "wavvoxNativeApp.c" include "licenseWavvox.c" // jm*20180520 include "driverGeneration.c" // jm*20170317 include "driver.c" include "process.c" include "buildPacket.c" // jm*20180315 include "buildPacketEmbed.c" include "Decode.c" include "fifo.c" include "filters.c" include "campaignCodeText.c" include "convertTextCode.c" include "transmitSymbol.c" include "transmit.c" srcDir "jni" } } // jni } // main } // sources } // android // jm*20190405
} // model
//dependencies {
// compile fileTree(dir: ‘libs’, include: [‘*.jar’])
// androidTestCompile(‘com.android.support.test.espresso:espresso-core:2.2.2’, {
// exclude group: ‘com.android.support’, module: ‘support-annotations’
// })
// compile ‘com.android.support:appcompat-v7:25.1.1’
// testCompile ‘junit:junit:4.12’
//}dependencies {
compile ‘com.android.support:support-annotations:25.3.1’
testCompile ‘junit:junit:4.12’
testCompile ‘org.hamcrest:hamcrest-junit:2.0.0.0’/** Dagger 2 */ // TODO: get the dagger-compiler annotation processor to work and use Dagger instead of ProviderModule
// compile ‘com.google.dagger:dagger:2.10’
// annotationProcessor ‘com.google.dagger:dagger-compiler:2.10’
// provided ‘javax.annotation:jsr250-api:1.0’
}/**
- Workaround for using ProGuard with the experimental Gradle plugin.
- Trouble seems to be that unless process(Debug|Release)Resources task is needed, it is not created
- and VariantOutputScope.setProcessResourcesTask in TaskManager.createProcessResTask() is not
- called so when TaskManager.applyProguardConfig() calls
- BaseVariantOutputData.processResouresTask.getProguardOutputFile() it does so on a null object.
- So, by making transformClassesAndResourcesWithProguardFor(Debug|Release) depend on
- process(Debug|Release)Resources I force the task to be created
- More discussions here: Google Issue Tracker
/
tasks.all { task →
def match = task.name =~ /^transformClassesAndResourcesWithProguardFor(.)$/
if (match) {
task.dependsOn “process${match.group(1)}Resources”
return
}
}
I realize that – with the oh so frequent syntax changes in Gradle, documentation and even adding essential warning and/or error messages is left behind and cannot keep up – but on such fundamental features (here: “model”) one can expect much more diligence. Please?
According to Google, Android Studio 3 is supporting the “experimental” model function. Sooo… What do we miss?
Thanks!
jm.