I am developing a basic map example but I'm in trouble with android studio.
I got this error :
Error:(9, 0) Cause: startup failed:build file 'C:\Users\Tugrul\AndroidStudioProjects\ServiceTextSender\build.gradle': 9: expecting '}', found ':' # line 9, column 31.
compile ‘com.android.support:appcompat-v7:+’1 error
And here an error resource from my build.gradle file(dependencies :
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
compile ‘com.android.support:appcompat-v7:+’
compile ‘com.google.android.gms:play-services:3.1.36′
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
How can I fix this? Could you help me please? I'm in trouble with Android Studio. I'm in trouble with this error.
Regarding the error:
Looks like you are adding this to the wrong gradle file, should be added to the app's gradle file (the one in the app's folder), not the module (the top one). The top one specifies the gradle plugin to use and as you have it listed here, I'm assuming you are editing the wrong build-gradle file.
If you instead check in the same directory that contains the src-folder (not inside src) you will find the app's dependencies section where you can add that line.
And/Or you are just using the wrong characters should be ' and not ‘.
Suggested easier solution:
Create a new Google Map Activity using the template when starting a new project, or right click in your project package and choose (in the popup menu):
New -> Google -> Google Maps Activity
And everything will be set up for you.
I think your problem is character error. ' and ‘ are different.
Try change this :
classpath 'com.android.tools.build:gradle:1.3.0'
compile ‘com.android.support:appcompat-v7:+’
compile ‘com.google.android.gms:play-services:3.1.36′
to this
classpath 'com.android.tools.build:gradle:1.3.0'
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:3.1.36'
Edit:
These are gradle Files:
You need to add your
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:3.1.36'
}
lines to Module Specific build.gradle file shown as above.
Related
I'm trying to use JSON Simple to parse a JSON file into Java in a Gradle JavaFX project.
I've tried a few things:
Adding implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1' to the build.gradle file. ... Won't let me do import org.json.simple.JSONParser;
Error: error: package org.json.simple does not exist
Adding implementation 'com.googlecode.json-simple:json-simple:1.1.1' to the build.gradle file. ... gives same error as above.
In IntelliJ, I've tried manually downloading and adding the jar file:
First I added a new directory to the root called 'libs' and added the jar file there. Went to File > Project Structure > Libraries > '+' > Java, selected the file and pressed the module I wanted to add it to. Then I added requires json.simple; into the module-info.java file.
IntelliJ does not come up with any errors, but when I do gradle run, it comes up with an error in the modules-info.java file that says error: module not found: json.simple
I have no idea why that last error is happening, I made sure the module was applied to the root as well (Where the modules-info.java file is.
I've tried gradle clean, invalidating caches and removing caches altogether.
If anyone knows why this issue is occuring (or can suggest another way I can parse a JSON file), that would be great!
Thanks in advance.
I have to use PKCS10 class into my project. I tried to import sun.security.pkcs.PKCS10; into my activity code but studio shows "Cannot resolve symbol PKCS10" at both places where I have imported it and where I want to instantiat it.
Note: I haven't added any dependency or library (like .jar) to my project.
I want to know whether can it be automatically?
The class sun.security.pkcs10.PKCS10 was removed from the JDK. Using a class that was internal and already removed from the JDK is going a step beyond just using an internal API.
Put this into your build.gradle file.
compileJava {
options.forkOptions.javaHome = file(System.properties['java.home'])
}
And if this does not work, put this into you build.gradle(app) dependencies.
compile group: 'com.sun', name: 'rt', version: '1.5.0_06'
I'm using angular 4 and ionic 3. Now when i run "ionic cordova run android"
It gives me the following error:
"more than one library with package name 'com.google.android.gms.license'"
My project.property file:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:27.1.0
cordova.system.library.2=com.android.support:support-v4:27.1.0
cordova.system.library.3=com.android.support:support-v4:27.1.0
cordova.system.library.4=com.android.support:appcompat-v7:25.+
cordova.gradle.include.1=cordova-plugin-firebase/starter-build.gradle
cordova.system.library.5=com.google.gms:google-services:+
cordova.system.library.6=com.google.android.gms:play-services-tagmanager:+
cordova.system.library.7=com.google.firebase:firebase-core:+
cordova.system.library.8=com.google.firebase:firebase-messaging:+
cordova.system.library.9=com.google.firebase:firebase-crash:+
cordova.system.library.10=com.google.firebase:firebase-config:+
My dependencies in build.gradle file :
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.android.support:support-v4:27.1.0"
compile "com.android.support:appcompat-v7:25.+"
compile "com.google.gms:google-services:+"
compile "com.google.android.gms:play-services-tagmanager:+"
compile "com.google.firebase:firebase-core:+"
compile "com.google.firebase:firebase-messaging:+"
compile "com.google.firebase:firebase-crash:+"
compile "com.google.firebase:firebase-config:+"
// SUB-PROJECT DEPENDENCIES END
}
Thanks in advance :)
Please update your build.gradle file
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
changes your version to 2.3.0
its worked for me...
Thanks
Change your project.property file to:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:27.1.0
cordova.system.library.2=com.android.support:support-v4:25.+
cordova.system.library.3=com.android.support:appcompat-v7:25.+
cordova.system.library.6=com.google.firebase:firebase-core:11.8.0
cordova.system.library.7=com.google.firebase:firebase-messaging:11.8.0
cordova.system.library.8=com.google.firebase:firebase-crash:11.8.0
cordova.system.library.9=com.google.firebase:firebase-config:11.8.0
cordova.system.library.9=com.google.firebase:firebase-auth:11.8.0
cordova.system.library.9=me.leolin:ShortcutBadger:1.1.4#aar
I think your issue comes here:
compile "com.google.gms:google-services:+"
compile "com.google.android.gms:play-services-tagmanager:+"
Rather than importing gms services like this, you should only import specific libraries.
You are using together those both library.
compile "com.google.gms:google-services:+"
compile "com.google.android.gms:play-services-tagmanager:+"
this "com.google.gms:google-services:+" library has all play service libraries.
Remove this dependency "com.google.android.gms:play-services-tagmanager:+" and it will work.
But still This is not a good way to add com.google.gms:google-services:+, because un-necessary you are adding all google's dependency.
Instead of this dependecy you can use specific dependency, for example if you are using map, then use only map play service.
Here is the list of all play service dependency https://developers.google.com/android/guides/setup .
I suggest you add only required dependency instead of play service universal dependency.
If you've already changed version at /android/build.gradle but not work yet. Maybe you need check some library package at node_modules.
Eg: react-native-onesignal also compile some play-services with highest version (they use +) so it can make this issue.
You can put a script at root directory and add {"scripts": {"postinstall": "node changeVersionGoogleService.js"}} in package .json so it can run to auto change your version when you npm install.
This is the script: https://gist.github.com/duytq94/47ef945131b61de538447d449813b3d4
My script at now auto change 'react-native-onesignal',
'react-native-admob',
'react-native-maps',
'react-native-google-sign-in'
None of the solutions discussed here worked for me so I went on to
renamed the /platform/android folder and Remove android platform
add android platform ionic cordova platform add android
faced another issue with facebook due to this which has a solution here where you need to add your app id and name in platforms/android/app/src/main/res/values/strings.xml file
compiled worked fine after that.
The problem occurred for me when upgrading to cordova 7.
just Add :
googlePlayServicesVersion=11.8.0
to your gradle.properties
have fun ...
I am quite new to React Native but I need to create an Android Module for the Honeywell CT50 barcode scanner.
I have created a libs folder in MyApp/android/app as stated in these two SO posts:
Post 1
Post 2
The second post says I must then add the package name to the dependencies something like this:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile 'com.facebook.react:react-native:0.19.+'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
}
This the part I am struggling with, the formatting of the name. Here's what the contents of the .jar file looks like:
I would like to reference the AidcManager to do this I have tried:
compile "com.honeywell.aidc.AidcManager"
compile "com.honeywell.aidc:AidcManager"
compile "com.honeywell.aidc:"
Each time I get an error during my build saying something like:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.honeywell.aidc:AidcManager:.
Searched in the following locations:
file:/Users/XXX/.m2/repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
file:/Users/XXX/.m2/repository/com/honeywell/aidc/AidcManager//AidcManager-.jar
https://jcenter.bintray.com/com/honeywell/aidc/AidcManager//AidcManager-.pom
https://jcenter.bintray.com/com/honeywell/aidc/AidcManager//AidcManager-.jar
file:/XXX/node_modules/react-native/android/com/honeywell/aidc/AidcManager//AidcManager-.pom
file:/XXX/node_modules/react-native/android/com/honeywell/aidc/AidcManager//AidcManager-.jar
file:/Users/XXX/Library/Android/sdk/extras/android/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
file:/Users/XXX/Library/Android/sdk/extras/android/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.jar
file:/Users/XXX/Library/Android/sdk/extras/google/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
file:/Users/XXX/Library/Android/sdk/extras/google/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.jar
Required by:
MyApp:app:unspecified
Can anyone point me in the right direction? Many thanks in advance.
Just copy .jar files in libs folder and import classes or packages from it in your .java file. There is no need to reference them in .gradle file.
Answering wayyyyyyy to late, but might be helpful to others who are looking for this answer,
just add .jar in libs, then add below into gradle
implementation files('libs/<YourJarName>.jar')
Or
Right click the jar and select "Add jar to project" option
I have a library I want to add to my Android Application. But the problem is that the library is separated into .java files. Now I have tried to add a module to do the job but it does not work. My problem is I do not know how to add a bunch of .java files to my Android project to use throughout my app. I am new to Android dev and I have looked around but cannot find a clear explanation of how to add my type of library to an Android project.
I can see a couple of problems in the screenshot that you just posted above.
1) It seems that you're not telling Gradle (and therefore Android Studio) that you have Java files that need to be compiled. You can fix that by adding this to the build.gradle of the TMDB-Lib module:
sourceSets {
main {
java {
srcDir 'libs'
}
}
}
and then adding the module to your settings.gradle.
2) It seems that the Tmdb classes don't have a package (i.e. their first line isn't a package declaration) so the right way to import them into your Java code is by using just their class name:
import TmdbApi;
instead of:
import TMDB-lib.libs.TmdbApi;