Reputation: 7193
This is a follow up to my question here: Could not find com.android.tools.build:gradle:3.2.1. in a sample project from github
I am trying to compile the project given here: https://github.com/dakatso/SpeexExample
To get rid of gradle sync errors, I had to first change the project level gradle.build and gradle-wrapper.properties file. The changes made are as shown in the linked question and it's answer (Could not find com.android.tools.build:gradle:3.2.1. in a sample project from github)
I'm however getting errors in the app level gradle.build files in both the /library and /sample folders. I have tried to make some modifications but I get an error that says compileSdkVersion is not specified
although it's specified in the file. I think this project was created using an older version of android studio and gradle, which do not apply to the latest android studio (4.0). Here are the app level build.gradle files (shows original code as well as my modifications):
build.gradle for /library:
// apply plugin: 'com.android.model.library' // ORIGINAL
apply plugin: 'com.android.library'
model {
android {
// compileSdkVersion = 24 // ORIGINAL
compileSdkVersion 26
buildToolsVersion = '24.0.0'
defaultConfig {
// ORIGINAL
// minSdkVersion.apiLevel = 9
// targetSdkVersion.apiLevel = 24
minSdkVersion 9
targetSdkVersion 26
}
sources {
main {
jni {
exportedHeaders {
srcDir 'src/main/jni/include'
}
}
}
}
ndk {
moduleName = 'speex'
platformVersion = '9'
toolchain = 'clang'
CFlags.add('-DFIXED_POINT')
CFlags.add('-DUSE_KISS_FFT')
CFlags.add('-DEXPORT=\"\"')
}
}
}
build.gradle for /sample:
// apply plugin: 'com.android.model.application' // ORIGINAL
apply plugin: 'com.android.application'
model {
android {
// compileSdkVersion = 24 // ORIGINAL
compileSdkVersion 26
buildToolsVersion = '24.0.0'
defaultConfig {
applicationId 'com.speex.speexsample'
// ORIGINAL
// minSdkVersion.apiLevel = 9
// targetSdkVersion.apiLevel = 24
minSdkVersion 9
targetSdkVersion 26
versionCode = 1
versionName = '1.0.0'
}
productFlavors {
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
create("all")
}
}
}
dependencies {
// ORIGINAL
// compile fileTree(include: ['*.jar'], dir: 'libs')
// compile 'com.android.support:appcompat-v7:24.0.0'
// compile 'com.android.support:design:24.0.0'
// compile project(':library')
implementation fileTree(include: ['*.jar'], dir: 'libs')
// implementation 'com.android.support:appcompat-v7:24.0.0' // ORIGINAL
implementation 'com.android.support:appcompat-v7:26.0.0'
// implementation 'com.android.support:design:24.0.0' // ORIGINAL
implementation 'com.android.support:design:26.0.0'
implementation project(':library')
}
What should be modified in these files to get this project to compile?
Upvotes: 3
Views: 20629
Reputation: 1
Open the app/build.gradle file and locate the line that reads:
compileSdk compileSdkVersion
Replace the above line with the following:
compileSdk rootProject.ext.compileSdkVersion
This change will ensure that the compileSdkVersion is correctly referenced from the project's root ext properties.
Upvotes: 0
Reputation: 573
In my case using plain old cordova I had simply not bootstrapped the project from the command line for the first time. Doing the following:
cordova build android
in the command line fixed the issue.
Upvotes: 0
Reputation: 152827
Looks like the gradle files are from an old experimental gradle plugin, and you've now changed it to the current library/application plugins.
You can likely get rid of the compileSdkVersion warning by removing the model { }
block and thus make the android { }
a top-level block. Expect to see more migration issues going forward.
Upvotes: 1