some strange android error - android

https://github.com/mustafaakin/image-matcher
I imported this project using AndroidStudio's "Import Eclipse Studio Project". Edited .properties 'OpenCV - x.x.x' to 'opencv'. This is the error:
/home/uttaran/Downloads/h1/h/src/main/res/layout/main_layout.xml
Error:(62) No resource identifier found for attribute 'camera_id' in package 'in.mustafaak.imagematcher'
Error:(62) No resource identifier found for attribute 'show_fps' in package 'in.mustafaak.imagematcher'
Error:Execution failed for task ':h:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/uttaran/Android/Sdk/build-tools/23.0.3/aapt'' finished with non-zero exit value 1
Information:BUILD FAILED

As Daniel K already stated correctly:
To important an Android Application/Library in Android Studio, the project you want to import needs a build.gradle or pom.xml file in the root of the project so that the build system (Gradle/Maven) that comes with Android Studio can resolve dependencies etc. during the project import...
The Github project you refering too is this?
https://github.com/mustafaakin/image-matcher
Apparently it got written with the Eclipse IDE...and pushed to Github without any build file...
You can import it anyway, by manually creating a build.gradle file in the project root and then try to import the application again.
A possible working build.gradle file (depends on your Android Studio's Gradle plugin Version etc. I just assume now you copied your build.gradle file from a working project of yours) would be:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
}
If you did this, it probably will not find the OpenCV library dependency (red lines under OpenCV classes/methods and in imports) and you have to go in Android Studio to:
File | Project Structure | image-matcher-master | Dependencies | +
And there you add your OpenCV library as "File dependency"...if it is a JAR...otherwise if opencv in your Download folder is the source...you load this in Android Studio as well and choose "Module dependency".
If this doesn't work...this could be helpful as well:
http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html
UPDATE:
main_layout.xml contains things like:
<org.opencv.android.NativeCameraView
android:id="#+id/tutorial1_activity_native_surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="cameraclick"
android:visibility="gone"
opencv:camera_id="any"
android:layout_weight="1"
opencv:show_fps="true" />
So your OpenCV library comes with resources and views that can't be found, so you still have some problem with your src structure in your project.
This answer might be related:
Android Studio can't find opencv modules, but compiles ok
If nothing works I would recommend to import an OpenCV Android sample, check if it builds and compiles and then compare the src structure difference from your project to the sample project...
Open the Android native Camera using OpenCV

Related

Android studio default project fails: Error:Failed to resolve: com.android.support:support-v4:25.2.0

I am literally just starting app development for the first time and the default project when I create a new one will not build. I have tried looking on Google and SO for these errors and have found some but their solutions do not work. Given that I have not edited the files at all, I presume it is an issue with Android Studio not being setup properly but can't figure it out. The errors are as follows:
Error:Failed to resolve: com.android.support:support-v4:25.2.0
Install Repository and sync project
Open File
Show in Project Structure dialog
Error:(23, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Install Repository and sync project
Show in File
Show in Project Structure dialog
Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.+
Install Repository and sync project
Show in File
Show in Project Structure dialog
The build.gradle file it points to is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.extremecomputing.spotzz"
minSdkVersion 17
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'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.google.android.gms:play-services-maps:11.0.1'
testCompile 'junit:junit:4.12'
}
I have tried with a previous project that I had created a few things I found online. Such as they had recommended the + in the version could cause unpredictable builds, but that wasn't it. One had recommended a few compile lines in the dependencies section, it changed the errors for a moment saying I needed to download something, I did then it went back to the original errors. I also have tried to make sure that the SDK tools are updated, and they appear to be. Any suggestions would be greatly appreciated.
Please be noted that support library from revision 25.4.0 to the latest, we need to add google maven. As in the release note says:
Important: The support libraries are now available through Google's
Maven repository. You do not need to download the support repository
from the SDK Manager. For more information, see Support Library Setup.
So you need to add the google maven to your root build.gradle like this:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Read more at Support Library Setup.
Try this:
in Android Studio, open Tools -> Android -> SDK Manager
under tab "SDK Tools" un-check the libraries causing problems
click "apply" to uninstall them
re-check the same libraries click "apply" to reinstall them
close SDK Manager and run Gradle sync / build
I had the same problem and it was due of an interference with another library.
In my case I had to comment:
compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)
Now it builds

Could not resolve com.android.tools.build:gradle:2.2.3

I'm working on a mobile app project for work, but often when I attempt to run the application it gives me the following error:
Error:A problem occurred configuring root project 'projectName'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:2.2.3.
Required by:
:projectName:unspecified
No cached version of com.android.tools.build:gradle:2.2.3 available for offline mode.
I have tried a number of different things including deselecting the Offline work checkbox in the settings and then closing and re-opening Android Studio, but nothing seems to fix the issue. It may build fine for a few times in a row, but that same error keeps popping up. Then I have to try variations of building and making the app, or exiting and re-opening Android Studios. Nothing consistently works though. Any insight into what may be causing this issue and how it can be fixed would be appreciated.
***Update: Upon request I have added below my app gradle content
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
useLibrary 'org.apache.http.legacy'
dexOptions {
javaMaxHeapSize "8g"
}
defaultConfig {
applicationId "com.example"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
debuggable true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile files('libs/gson-2.2.2.jar')
compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.loopj.android:android-async-http:1.4.9'
}
It turns out the solution to my particular issue was relatively simple. The error message was a bit deceiving as this was not a problem with the offline mode switch, but rather confusion with the gradle file. Here are a few steps I took to fix the issue:
For Android Studio 2.3 go to File>Settings>Gradle and select the "Use default gradle wrapper" option. Also make sure the checkbox next to "Offline work" is unchecked just in case.
Click the "Apply" button
Within the build.gradle file (the one named after your project) under the "Gradle Scripts" section of Android Studio make certain that your current build gradle class path matches the current version of Android Studio. An example for Android Studio 2.3:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
Also within the Gradle Scripts section make sure that your gradle-wrapper.properties file is referencing the correct gradle file in the distribution URL. For example for gradle 3.3:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Navigate to C:\Program Files\Android\Android Studio\gradle and ensure there is a gradle folder with the same name as the gradle you are using. In my case I ensured there is a folder named gradle-3.3 with a zip file named gradle-3.3-all.zip. It is relatively easy to find this zip file online.
Delete the .gradle folder in C:\Users\yourUser with yourUser being whichever user your Android Studio project is under.
Close Android Studio and restart. It should begin the gradle sync process and rebuild the .gradle file.
For me when I did this it also complained about not finding the gradle-3.3-all.zip file in the .gradle folder. I was able to fix this by adding the gradle-3.3-all.zip file to C:\Users\yourUser.gradle\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9. I'm not sure if the folder has the same name for everyone, but whatever the name, that is the location I went to. If all this doesn't work I would try a variation of these steps, and hopefully it works for you.
The reason why it is failing is because it could not compile one of the libraries you included. Perhaps, try removing the one you suspect and try again. But most of the times, a rebuild of the project should resolve dependencies.
I've had the same pb, managed to resolve it adding in gradle.properties
systemProp.https.proxyHost=<my proxy hostname>
systemProp.https.proxyPort=<my proxy port>
I was missing HTTPS property, there was only HTTP setted so it was working sometimes, and not for the https links gradle used.

Android studio gradle error, "configuration with name default not found" with aviary sdk

First of all, I know there are a lot of subjects about this problems, but I still can't fix it.
I'm just trying to customize aviary sdk by following the guide here : https://developers.aviary.com/docs/android/setup-guide# (section 4.2, not 4.1)
here are my root gradle files :
build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
settings.gradle :
include ':app', ':Aviary-Android-Sample-App'
here is my app build.gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.agaze.myapplication"
minSdkVersion 10
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:20.0.0'
compile project(':Aviary-Android-Sample-App')
}
Here my files tree:
Thanks in advance for your tips.
Antonin
Check your submodules and make sure each submodule in your project has its own build.gradle file.
Check this guide for more info
tools.android.com/tech-docs/new-build-system/user-guide
Each library you add to your project should have it's own build.gradle file. If it does not have you can get this error.
For a solution you can add your sdk as a module with Android Studio. To do this you can follow the path in Android Studio:
File > New > Import Module and select directory of your sdk and add to your project.
Select Gradle System and let Android Studio create gradle files for your sdk.
You can check the link below for more information and how to add a module to your project.
http://www.truiton.com/2015/02/android-studio-add-library-project/
I hope this'll help you.
From your screen shot.It's obvious that the Aviary-Android-Sample-App is an eclipse project(no gradle file there) but not a valid gradle module.
If you want to import it into android studio, in android studio, click File -> new module -import eclipse adt project and go on under the instruction.
And you are good to go.
Edit:
Also, it seems that you want to modified the Aviary sdk, but the module you want to import is a sample app. Maybe you have downloaded the wrong file. The correct link looks like this one https://creativesdk.adobe.com/downloads.html

Freshly imported Android Studio project errors with zxing module

I have been using zxing module as an android library for some time without problems. I have imported my Eclipse project into Android Studio (which I use for everything else!) and the zxing library is added as a module.
In one of my classes in the main module I reference the com.google.zxing.android.client.Intents class which is in the zxing module. I can write code in Android studio and these references have the correct imports selected.
When I run a gradlew clean build I am getting messages saying 'cannot find symbol class Intents'.
In settings.gradle I have includes for both my main module and the zxing module.
In the build.gradle of my main module I have 'compile project(':zxing'). These were both added during the import from Eclipse. I can also see that the zxing module is being built as part of the gradlew clean build.
I have tried deleting the zxing module and references then trying to add it manually. I have compared the way that this module is implemented to another project with a similar module that works. All looks fine.
Is anyone able to make a suggestion?
Edit:
settings.gradle file
include ':app'
include ':captureActivity'
build.gradle of main module
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.wigglyamps.littlegreenbutton"
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':captureActivity')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Java class file in main module
public class test {
public void hello () {
String i = Intents.Scan.ACTION;
}
}
I don't really know the zxing framework, but have you tried to use the maven artifact instead of referencing a module?
If you want to use the artifact add this to the dependencies of the project/module that uses zxing: compile 'com.google.zxing:core:3.1.0'
Edit: You said you imported the project from eclipse; I'm in the middle of transitioning to gradle and the import function hardly produces anything useful if the eclipse project contained references to library projects (not jar's). I rebuild my projects from scratch by creating a new app(with modules) in Android Studio and copy/paste code and resources into the new app's directories

Android Studio and Gradle - build fails

I am building a small library project along wit a sample project to illustrate the use. I can't manage to run the sample in Android Studio. I have created the project from scratch. I am experienced with Eclipse but it's my first try at Android Studio & Gradle.
The error given:
Gradle: Execution failed for task ':demo:dexDebug'.
Running C:\DevTools\Android\android-studio\sdk\build-tools\android-4.2.2\dx.bat
failed. See output
I have the following folder structure:
- demo
- build
- libs
- android-support-v4.jar
- src
- main
- java
- res
- build.gradle
- library
- build
- libs
- android-support-v4.jar
- src
- main
- java
- res
- build.gradle
- build.gradle
- settings.gradle
Build.gradle at project root:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
Settings.gradle at project root:
include ':library', ':demo'
Build.gradle for the library module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Build.gradle for the sample module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile project(':library')
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Specifying compile files('libs/android-support-v4.jar') means that every library includes support v4. What you want to do is just specify that every library depends on it:
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
This will allow gradle to detect all dependencies and include this only once.
Note: You have to first use the SDK Manager and download and install two Maven repositories: "Android Support Repository" and "Google Repository".
I found the problem:
I removed that line from the sample gradle file.
compile files('libs/android-support-v4.jar')
However, I have no idea why this does not work (if I have 2 or 3 external libraries that all depend on the support library, how are we supposed to do, without touching their gradle files?
You should navigate to your libs folder in the IDE, right click on the jar and select to add the library to the project, it still needs to establish the dependency even though the jar appears to be there. Also look at your gradle built script to make sure the dependency appears there. If that still doesnt work just run a gradle clean on the project. Intellij documentation will give you more details on what clean does. see:
stackoverflow gradle build
This error could be encountered while migrating from Groovy to kotlin DSL as well and here are the steps to get rid of it:
If you are still in the process of migrating please complete the migration of gradle files first, use kts syntax and then sync gradle files.
Use this dependency inside your build.gradle(app level):
implementation("androidx.legacy:legacy-support-v4:1.0.0")
Remove id("kotlin-android-extensions") from plugins block inside build.gradle.kts (app level).
That's it! 3rd Point solved the issue for me but trying all the points should definitely fix the issue.
In my Case replace this line
classpath "com.android.tools.build:gradle:7.0.2"

Categories

Resources