Gradle build Error:Cause: org.gradle.api.internal.ExtensibleDynamicObject - android

I am trying to import 'https://code.google.com/p/android-serialport-api/'into Android Studio. Since this project involves ndk, I followed the instructions to build NDK from the following link: http://tools.android.com/tech-docs/new-build-system/gradle-experimental
But after building, I get this error:
Gradle Project refresh Failed
Error:Cause: org.gradle.api.internal.ExtensibleDynamicObject
EDIT: I have 2.5 gradle version installed
Here's my build.gradle
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig.with {
applicationId = "android_serialport_api.sample"
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 22
android.ndk {
moduleName = "serial_port"
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.productFlavors {
create("all")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
}

Can you try change
compileSdkVersion 22
buildToolsVersion "22.0.1"
to
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
and
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
to
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
I've got the same error and this works for me.

Unfortunately the NDK preview implementation to support native code development in Android Studio is a moving target. Even if you use an older, developers.android.com stated, "supported" combination of the experimental Android Gradle plugin (from tools.android.com) and Gradle version (from gradle.org), good luck in getting the build to work. Instead, always use the latest released combination with the latest indicated module build.gradle language syntax, according to developers.android.com.
In your case, your mixing the use of assignment operators, "=" and "+=". Depending on the supported combo of gradle plugin and gradle version you're using, it's either use the assignment operators everywhere in module build.gradle file or nowhere - you have to be consistent, all or nothing. For "+=" use the method ".add(...)" instead.
And remember, the gradle scripting language is compiled to the Java runtime so when you see a build error that looks like a Java error, it's the gradle scripting that is likely the problem.

I got this error when I had a parameter not correctly moved from old gradle syntax to new one
(had cFlags "..." rather than CFlags += "...")
Have a look e.g. at http://tools.android.com/tech-docs/new-build-system/gradle-experimental

Related

Using 'model.android.ndk' command in build.gradle

I'm using gradle 4.4 and I can't the 'ndk' command is not found. This is my build.gradle of the application:
apply plugin: 'com.android.application'
apply plugin: 'cpp'
android {
System.setProperty('SYS', 'android')
compileSdkVersion 23
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "xxx"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
model {
android.ndk {
moduleName "native-lib"
}
}
I don't know what the problem is but i get the error:
The following model rules could not be applied due to unbound inputs
and/or subjects:
android.ndk { ... } # app\build.gradle line 27, column 5
subject:
- android.ndk Object [*]
[*] - indicates that a model item could not be found for the path or
type.
which refers to the line of the 'ndk' command.
Thanks!
Google essentially discontinued the experimental NDK plugin. Please follow their official guide to migrate to the stable plugin: Migrate to Stable Gradle for NDK Support using CMake and ndk-build.
If you have problems with this tutorial, and you need more guidance, please don't hesitate to ask here.

Avoid 'Variant Selection Conflicts' warning when using android test plugin without release variant

What I want to do & the problem
I updated my Android Studio and Android Gradle Plugin to 3.0.1 and my Gradle Wrapper to 4.1 and can build & deploy my Android Gradle project in release variant on a device via IDE.
However, the following 'Gradle Sync' warning messages are shown:
Warning:Module 'library' has variant 'release' selected, but the modules ['integration-test'] depend on variant 'debug'
The problem here is, that there is no 'release' variant for the integration-test module which uses the 'com.android.test'
plugin.
If I simply try to add a release build type (buildTypes { release {} }) to the :integration-test module I receive:
Error:VariantInputs initialized with no merged manifest report on: DEFAULT
Details about the project (simplified)
The project consists of:
a :library module
an :app module which builds the app's apk and uses the :library module
an :integration-test module which:
uses the "com.android.test" plugin
dependents on the :app module via targetProjectPath ':app' & targetVariant 'debug'
and contains instrumented tests on the :app functions
only contains a 'main' folder (the test plugin does not support others)
This project is build after the Android Test Blueprint as the goal is here that the :app module does not know anything about the integration-test module's existence.
settings.gradle
include :library
include :app
include :integration-test
app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
publishNonDefault true
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
applicationId "xxxxx"
testInstrumentationRunner rootProject.ext.testInstrumentationRunner
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
release {
keyAlias 'xxxx'
}
}
buildTypes {
debug {
testCoverageEnabled = true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
// This is needed by the integration-test module (i.e. com.android.test : integration test)
// in order for targetVariant to work without a flavor
publishNonDefault true
testOptions {
unitTests {
// Required so that logging methods do not throw not mocked exceptions in junit tests.
returnDefaultValues = true
}
}
compileOptions {
sourceCompatibility rootProject.ext.sourceCompatibility
targetCompatibility rootProject.ext.targetCompatibility
}
}
dependencies {
// Local dependencies
compile project(':library')
// i cleaned up all the other dependencies as they wouldn't help here
}
Question
Did anyone get an (integration-)test module using the com.android.test plugin to run with Android Gradle Plugin 3.0.1 without getting the "no release variant" error? If so, how can I avoid this error or how can I add such a release variant to a android test plugin based module (if this makes sense at all)?
I was also getting
VariantInputs initialized with no merged manifest report on: DEFAULT.
Then I followed exactly what is outlined in the https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint
The error went away when I removed release buildType from the `buildTypes' block in the test module's Gradle file.
From this:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
to
buildTypes {
}

Android JACK compiler error after upgrade to latest support library

--Android Studio 2.2.3 (Windows 10 64 bit)
--Build Tools version 25
--Android Gradle Plugin Version 2.2.3
After upgrade to latest support libraries (25.1.0 from 23.4.0) and change of compile version (25 from 23) I get this error:
Error:com.android.sched.util.config.PropertyIdException: Property 'jack.library.import' (in Options): element #7: The version of the library file '..\app\build\intermediates\transforms\preJackPackagedLibraries\debug\jars\8000\1f\classes-1b6639e8217419d056942b0dacd1542739f1709f.jar' is not supported anymore. Library version: 3.2 - Current version: 3.3 - Minimum compatible version: 3.3
...
BUILD FAILED
Has anyone ever had this problem? In the mentioned .jar file I can find some AnimatedVectorDrawble related files. My app build.gradle
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "package"
minSdkVersion 14
targetSdkVersion 25
versionCode 111
versionName "1.1.1"
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
jackOptions.enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
maxProcessCount 4
javaMaxHeapSize "2g"
}
buildTypes {
release {
minifyEnabled false
useProguard false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
useProguard false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".dev"
versionNameSuffix "-DEV"
ext.enableCrashlytics = false
}
}
}
Based on the error message, it appears that Jack-enabled builds do not handle all cases where you update Gradle build settings. Jack keeps a cache of pre-compiled stuff (preJackPackagedLibraries), and something that you changed caused Jack to not like that pre-compiled material. Ideally, the build system would detect this case and simply re-compile it, but apparently it does not.
Cleaning the project (Build > Clean Project) hopefully clears up this problem in all cases.

Android Studio 2.0's inline compiler does no longer recognize native code

I am currently working on a library that contains Java and native code.
The build works well, and so does the execution of the code when this lib is used by a client application. But the inline compiler of Android Studio 2.0 beta 2 does no longer recognize my NDK code properly (while this was OK with Studio 1.5):
All natives appear red in the Java code while they are properly mapped through JNI_OnLoad():
The whole C code is highlighted in red as Studio cannot find the includes and symbols:
...
I didn't have this problem before switching from Android Studio 1.5 to Studio 2.0 beta 2. Studio was able to reverse engineer the code in a way the JNI_OnLoad() mapping between the Java native methods and native C code was detected. #include<> directives and so on were OK too.
I don't know how to restore this behaviour: I investigated in developer.android.com and here in SO but I found nothing about that. I also digged into the Studio Settings with no success. I'm still investigating though.
My Gradle settings follow:
Gradle version: 2.10
gradle.properties:
android.useDeprecatedNdk = true
Project's build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module's build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultPublishConfig 'release'
publishNonDefault true
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
ndk {
moduleName "mylib"
ldLibs "log"
}
debuggable false
jniDebuggable false
minifyEnabled false
}
debug {
ndk {
moduleName "mylib"
ldLibs "log"
cFlags "-g"
}
debuggable true
jniDebuggable true
minifyEnabled false
}
}
productFlavors {
library {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
As I suspected the debug info to be missing for the IDE to do the reverse engineering properly, I also tried using exactly the same config for debug and release (with the -g flag on, debuggable true, and jniDebuggable true), but this doesn't change anything.
EDIT, 20160212: researches led me to think this is a bug in the NDK integration of Studio 2.0, so I opened a Google Code ticket.
This has been fixed in Android Studio 2.2, but only for 64 bits. The deprecated NDK toolchain must be replaced by CMake in the project configuration.

error: package xxx does not exist . how do include packages in the build correctly?

I'm trying to use the project android-wheel from https://code.google.com/p/android-wheel/
with Android Studio.
I imported them as modules and put the dependency for 'wheel' into the build.gradle of 'wheeldemo'.
when building it with gradle it shows errors, that packages do not exist, even though the imports in the java file don't show any errors:
I'm not sure, what I'm missing here. Might be something obvious, since I'm not to familiar with android programming, yet.
edit: here is the build.gradle of the wheeldemo module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'kankan.wheel.demo'
minSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile project(':wheel')
}
Make sure the build.gradle of "wheel" has correct plugin type. It should be 'android-library' instead of 'com.android.application'.

Categories

Resources