I am trying to run an AR sample app from: https://artoolkit.org/documentation/doku.php?id=4_Android:android_examples
I tried to open the project ARSimpleProj. But it gives me this error:
Error:Cannot set readonly property: proguardFiles for class: com.android.build.gradle.managed.BuildType
I am using Android Studio 2.2.2 and Gradle 2.14.1
Thanks!
According to this description , in version 0.4.0 , '+=' was desabled and instead use ".add()" for it . So make the statement
proguardFiles += file('proguard-rules.pro')
change to
proguardFiles.add(file('proguard-rules.pro'))
and the error will disappear
The build.gradle file now looks like the following ...note the changes..there are 2-3 changes done but now working absolutely fine.The code is below:-
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "org.artoolkit.ar.samples.ARSimple"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
versionCode = 1
//Integer type incremented by 1 for every release, major or minor, to Google store
versionName = "1.0" //Real fully qualified major and minor release description
buildConfigFields.with {
//Defines fields in the generated Java BuildConfig class, in this case, for
create() { //default config, that can be accessed by Java code
type = "int" //e.g. "if (1 == BuildConfig.VALUE) { /*do something*/}".
name = "VALUE"
//See: [app or lib]/build/generated/source/buildConfig/[package path]/
value = "1" // BuildConfig.java
}
}
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.pro'))
}
}
android.productFlavors {
}
android.sources {
main{
jni {
source {
srcDirs = ['src/main/nop']
}
}
}
main{
jniLibs {
source {
srcDirs = ['src/main/libs']
}
}
}
}
}
dependencies {
compile project(':aRBaseLib')
}
I got the same error last a few hours. I solved by changing build type as follow -
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
}
}
After that I deleted all ndk imported code line. So my build.gradle of aRSimple is -
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "org.artoolkit.ar.samples.ARSimple"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
versionCode = 1
//Integer type incremented by 1 for every release, major or minor, to Google store
versionName = "1.0" //Real fully qualified major and minor release description
buildConfigFields.with {
//Defines fields in the generated Java BuildConfig class, in this case, for
create() { //default config, that can be accessed by Java code
type = "int" //e.g. "if (1 == BuildConfig.VALUE) { /*do something*/}".
name = "VALUE"
//See: [app or lib]/build/generated/source/buildConfig/[package path]/
value = "1" // BuildConfig.java
}
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
}
}
android.productFlavors {
}
}
dependencies {
//compile 'com.android.support:support-v4:23.0.1'
//compile 'com.android.support:appcompat-v7:23.0.1' //Only required when the target device API level is greater than
compile project(':aRBaseLib')
} //the compile and target of the app being deployed to the device
Then I create and copied all the .so library file into the jnilibs in applicaion main folder as show in fig
fig
Then run yours. I don't know this is the solution for this. But the errors go and project run without errors. Tell me if you find any other solution for this. Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With