Showing no OpenCV module in dependancies in Android Studio - android-studio

I tried many tutorials and blogs for Setting up OpenCV Android Library on Android Studio
some of them are here
A Beginner’s Guide to Setting up OpenCV Android Library on Android Studio
Add OpenCV library into Android Studio
OpenCV in Android Studio
but i am unable to configure it according to above solutions
at start when i try to import module from /OpenCV-android-sdk/sdk/java android studio not showing module name edit box and hence i have to add "java" as a OpenCV module name
OK after importing module with the name of java we have to add dependencies but in add module dependencies not showing any module name java or anything
Guys anyone know how can i resolve this issue or any proper steps for OpenCV configuration in Android studio
I am using
Android Studio -4.0
opencv-4.3.0-android-sdk

First Screenshot: Android Studio may have removed that option in new version.
Second Screenshot: You can solve issue by editing build.gradle of Opencv as below:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
//applicationId "org.opencv"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Change apply plugin: 'com.android.application' to apply plugin: 'com.android.library'
and comment out the following line :
applicationId "org.opencv"

Related

How to Migrate my flutter project in Android Studio to Android X Compatibility while I have tried everything mentioned in the official document.?

I have been building a Flutter App in Android App, it was all working fine, as soon as I used GeoLocator Library, my app crashed stating it is incompatible with AndroidX. When I try to Migrate my code to AndroidX, it says "You need to have compiled SDK set to at least 28 in your module build. Gradle to migrate to AndroidX. I have already set it to 28, but it still doesn't work.
In order, to resolve this. I have tried all the steps mentioned in Flutter Documentation.
Link: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
1. In android/gradle/wrapper/gradle-wrapper.properties change the line starting with distributionUrl like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
2. In android/build.gradle, replace:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
by
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
3. In android/gradle.properties, append
android.enableJetifier=true
android.useAndroidX=true
4.In android/app/build.gradle:
Under android {, make sure compileSdkVersion and targetSdkVersion are at least 28
5.Replace all deprecated libraries with the AndroidX equivalents. For instance, if you’re using the default .gradle files make the following changes:
In android/app/build.gradle
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
by
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Finally, under dependencies {, replace
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
by
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
This is some of my build.grade file where I have set the SDK version :
enter code here compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "co.appbrewery.clima"
minSdkVersion 28
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Tried all the things above, still getting an error that changes your SDK version to at least 28 whenever I try to set it Migrate to Android X using the Android Studio feature.
I would recommend using android studio feature to migrate the project to android X, instead of doing it manually.
From the source: Migrate the project to android X using android studio
With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
Do it with android studio.
Open the project in the studio and change the minSdk version to 23. You need to update the gradle version also and make it to more than 3.6.0. than go to refractor. There you will get the option of migrate to Android x .and do refractor. It will ask you to take the backup. And after that at the bottom you will get the popup of "Do Refractor". and that's it.

kotlin version that is used for building with gradle (1.1.2-5) differs from the one bundled into the IDE plugin (1.1.2-4)

Has anyone solved this issue?
kotlin version that is used for building with gradle (1.1.2-5) differs from the one bundled into the IDE plugin (1.1.2-4)
I am using AS 3.0 Canary 4
I followed Miha_x64's advice and upgraded the plugin which solved my problem:
Tools -> Kotlin -> Configure Kotlin Plugin Updates -> Check for updates now
My version of Android Studio is:
Android Studio 3.0.1
Build #AI-171.4443003, built on November 9, 2017
In my case, I converted Java to Kotlin and I have already Kotlin installed with lower version. So I updated it.
Tools -> Kotlin -> Configure Kotlin Plugin Updates then Check for updates now then choose Stable
.
But it didn't update my version in the build.gradle file automatically. Because it detected a newer version and differs from the old one.
So I manually updated my version to the latest from
ext.kotlin_version = '1.0.0' to ext.kotlin_version = '1.2.41'
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
There's an issue in Android Studio 3.0 Canary 4 that prevents it from loading the updated version of the Kotlin plugin. You can ignore the warning shown by the Kotlin plugin in build.gradle until a newer version of Android Studio 3.0 is released.
I also had the same issue, I am using Android Studio 3.2.1
Change the Kotlin version of your project build.gradle file(not module build.gradle file) to latest(at the moment it is 1.3.11)
ext.kotlin_version = '1.3.11'
then there will be notification call Kotlin migration, click Run migrations link on the notification.
Go to plugins then uninstall kotlin then restart ide then once android studio is back up drop down tools then select kotline then configure updates, it should be checking for new updates.
add this in your build gradle app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
[![In my case I had to downgrade to Gradle 7.2.2
]1]1

Glass Development Kit installed but not found by Android Studio

I get a Gradle Sync error saying "Failed to set up SDK": Error: Module 'app': platform 'Google Inc.:Glass Development Kit Preview:19' not found.
I have Glass Development Kit Preview from Android API 19 installed. My build.gradle(Module: app) is updated to reflect that:
compileSdkVersion 'Google Inc.:Glass Development Kit Preview:19'
buildToolsVersion '25.0.0'
I've looked at similar problems and I seem to have my build.gradle set up properly. How can I get the Gradle Sync to recognize my GDK?
You can try using the base build Tools for GDK:
android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion "19.1.0"
}
Download Android 4.4.2 or API 19.
Or try using this link . It creates a new project of GDK, and you can check how gradle looks afterwards.

Android Studio 2.1 does not generate signed Apk after updating

Recently, I've updated my android studio from 1.3 to 2.1. After that, when I trying to create a signed apk from "Generate Signed APK" in build menu. Android studio seems to works fine and prompting for successful generating release file, but always there is not such apk file in selected output folder. Also, open directory from successful pop up message does not work.
I try creating new keystore for signing and reinstalling android studio as suggested in some posts, but there is no change on issue..
This is build.gradle file I am using:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.vcc4.homeui"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/gson-2.6.2.jar')
compile 'com.android.support:design:23.4.0'
}
I encountered the same problem. And I found out that the generated apk was moved from the "app" folder to the "app/build/outputs/apk/" folder.
I do not know if it's a bug or a feature but it probably has something to do with "Automatically Sign Your APK", as this article https://developer.android.com/studio/publish/app-signing.html#release-mode describes the folder mentioned above.
I ran into the same issue today. I restarted Android Studio and that could have solved the issue -- in the meantime, I had issues with ProGuard etc. that started failing my build, so maybe some Gradle sync, project rebuild etc. also came in handy
But I have a sneaking suspicion this is to do with restarting maybe AS or even your machine. I ran into this same issue last time I was trying to build a signed APK and everytime this seems to take up a few of my hours....I need to figure this out too
it seems that the apk generated will be in
{project-folder}/app/release/app-release.apk

Unable to access CardBuilder class

I'm using Android Studio to build a Glass app, with my SDK Manager updated to GDK Preview API 19 Revision 9, and my device is on XE 21.3. I'm trying to use the new CardBuilder class, but it isn't available. I can still use the deprecated Card class, but the new stuff just won't show up.
I even uninstalled/reinstalled the Android 4.4.2 packages, but nothing. The same occurs when I load the project in Eclipse, too. I'd like to not use the Card class, as this is for a demo tutorial.
Got any tips on how to force this?
It took me several minutes before Android Studio was able to recognise the new class. You shall delete the build folder and start a clean compilation. There is a problem with classes already compiled with previous version of the GDK which are not noticed for recompilation.
Mine finally got repaired...today's Android SDK update to 23.0.5 seemed to do the trick...that and playing with the External Libraries menu in the Project panel to make sure the new class was available and then manually adding the namespace. Whew.
Thanks for your help everybody! :)
I thought it might be that but it's the same as the Google SDK Sample Projects, but here's what I've got:
apply plugin: 'com.android.application'
repositories {
jcenter()
flatDir {
dirs 'prebuilt-libs'
}
}
android {
compileSdkVersion 'Google Inc.:Glass Development Kit Preview:19'
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 19
targetSdkVersion 20
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
This is why I've stuck with Eclipse for Glass development. Android Studio has been too flaky again and again... I do use Android Studio for standard Android development

Resources