I am trying to import a OpenCV sample I got from http://ee368.stanford.edu/Android/OpenCV/ to Android Studio on a windows machine.
However, I'm getting the following error
* Project CVCamera MSER:C:\AndroidDevelopment\CVCamera_MSER\project.properties:
Library reference ..\..\android-jni could not be found
Path is C:\AndroidDevelopment\CVCamera_MSER\..\..\android-jni which resolves to C:\android-jni
Any ideas?
EDIT - more info:
I'm using the experimental gradle plugin
`classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha7'
And my gradle file is as follows:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig.with {
applicationId "co.vispera.moka"
minSdkVersion.apiLevel 17
targetSdkVersion.apiLevel 23
versionCode 1
versionName "1.0"
}
}
android.ndk {
moduleName = "mymodule"
// ldLibs.addAll(['log'])
// cppFlags.add("-std=c++11")
// cppFlags.add("-fexceptions")
// stl = '
}
}
1.Maybe your sample's default API version codes are too low.
If you're using Android Studio, try changing build.grade Version codes to newer ones.
example:
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
}
}
2.If same thing happens, try copying OpenCV libs folder to your project.
Copy OpenCV libs folder,(OpenCVPath/sdk/native/libs)
and paste it inside your app's 'main' folder.
Don't forget to rename it to 'jniLibs'.
Related
I imported a project downloaded from GitHub into my Android Studio project as module.
The "Import module..." wizard worked fine, but when the Adroid Studio tried to rebuild the project, it returned me this error:
Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File
The error is related to this line in the "build.gradle" file of the imported module:
compileSdkVersion rootProject.compileSdkVersion
I tried to add "ext" section in the project "build.gradle" like this:
ext {
compileSdkVersion 26
}
But in this way I receive a new error:
Gradle DSL method not found: 'compileSdkVersion()' Possible causes: ...
In your top-level file use:
ext {
compileSdkVersion = 26
}
In your module/build.gradle file use:
android {
compileSdkVersion rootProject.ext.compileSdkVersion
...
}
Another way:
Your build.gradle in top-level module
ext {
minSdk = 21
targetSdk = 29
compileSdk = 29
buildTools = '29.0.3'
}
Your build.gradle in app module
android {
def buildConfig = rootProject.extensions.getByName("ext")
compileSdkVersion buildConfig.compileSdk
buildToolsVersion buildConfig.buildTools
defaultConfig {
minSdkVersion buildConfig.minSdk
targetSdkVersion buildConfig.targetSdk
}
// ...
}
In build.gradle you need to write compilesdkversion under android tag as in this example:
android {
..
compileSdkVersion 26 // 26 is an example
..}
By the way. You can build that module as library then import it into your project as .aar file.
Change your .gradle android part to this
android {
compileSdkVersion 26
defaultConfig {
applicationId "your App id"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
I'm building a complex project with multiple modules that gets build together to create a distributed sdk.
My purpose is to have one variable for version major, minor and revision who I later inject into the buildConfig.
Cant find how to do it.
This is what I tried so far:
project1:
// PROJECT VERSIONS
project.ext {
major = 1
minor = 7
revision = 2
}
project2:
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode project(':project1').ext.major
versionName "1.0"
}
Thank you!
You can configure these values in the build.gradle file in the root of the project.
Example:
ext {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
minSdkVersion = 15
targetSdkVersion = 23
}
Then in the module/build.gradle you can use:
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
//...
}
In the beginning of build.gradle of project2 add the following line:
evaluationDependsOn(':project1')
Then the evaluation you wrote will work.
I'd like to change the path for where my assets live. This is because these assets will change often and are shared with other apps (i.e. iOS app) in another build folder. How can I do this?
To change the asset path you can tell your project to point to a different directory using the sourceSets command in your apps build.gradle file.
Here's how the build.gradle file looks like:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
sourceSets {
main {
assets.srcDirs = ['../../../build/android-assets']
}
}
...
Masters,
Recently I am trying to build android project with gradle, and since there one API(#JavascriptInterface annotation) I need to use is only up to api level 17, so I changed my targetAPILevel to 19 in project properties. And it works well when I build the project from Eclipse(Right click on project and Run Android Application).
But when I tried to build the project by gradlew in terminal, it seems it never use target level 19 to build the project. Here is part of the build.gradle file as follow:
android {
// target = 'android-19'
compileSdkVersion 19
buildToolsVersion '19.0.1'
}
Can anyone help me what I did wrong in here, please? Thank you very much.
TargetSdkVersion and compileSdkVersion are different parameters.
In eclipse, you set the target in your Manifest, and set the api used to compile with right click -> properties -> Android Manu.
In your build.gradle you should use something like this:
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
}
Rather than duplicating the android configuration block in each of the sub projects:
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 14
}
}
I would much rather put this in the top-level/root gradle build file like:
subprojects{
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 14
}
}
}
However, this doesn't work. :(
Error:
"..Could not find method android() for arguments..."
The solution to this turned out to be:
subprojects{
afterEvaluate {
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 14
}
}
}
}
As far as I know, this is because to process/use the android{...} at evaluation time means it must be present (ie. explicitly written or included as part of an 'apply plugin') as soon as it hits the subprojects in the root build file. And, more accurately, it means that the top-level project must have it defined (which it likely doesn't because it might not be an 'android' or 'android-library' build itself). However, if we push it off to after the evaluation then it can use what is available within each subproject directly.
This question + solution also assume that all subprojects are some form of android project (in my case true, but not necessarily for others).
The safer answer would be to use:
subprojects{
afterEvaluate {
if(it.hasProperty('android')){
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 14
}
}
}
}
}