Adding Google Maps Activity gradle build permanent failure - android

I have simply went through and attempted to add a a Google Map Activity in Android Studio, ie. Right click -> New -> Google -> Google Maps Activity,
Upon completion, the app attempted to build, and subsequently crashed during the build displaying the error:
Gradle 'appname' project refresh failed
Error: exception during working with external systems
Now, the src folder and manifest file have disappeared and any method including the most basic, super.onCreate display "Cannot resolve method"...
When attempting to clean the project it notes:
Error:The markup in the document preceding the root element must be well-formed.
Error:Cannot read packageName from C:\.....\appanme\app\src\main\AndroidManifest.xml
The build.gradle (Project: appname) file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle (Module: app) file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.example.appname"
minSdkVersion 14
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
// Additional
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.squareup.picasso:picasso:2.5.1'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:palette-v7:22.2.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.android.support:appcompat-v7:22.2.0'
}
Why would this happen? How can it be resolved?
UPDATE
AndroidManifest.xml: This code was merged with the manifest, breaking the app
<<<<<<< Original
...
...
</manifest>
=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application>
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="#string/google_maps_key"/>
<activity android:name="com.example.socialActions.RestaurantLocationActivity"
android:label="#string/title_activity_restaurant_location">
</activity>
</application>
</manifest>
>>>>>>> Added

The manifest has merge conflicts, review it and remove the <<<< parts and any duplicate / outdated info. Alternately if you're in Android studio you should be able to view file history and revert to an earlier version if you are confused.

Related

Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. > java.lang.UnsupportedOperationException (no error message)

I am not sure why this is happening, but I did some digging and tried to find other solutions. None worked out especially duplicate questions:
android {
compileSdkVersion 26
buildToolsVersion "23.0.3"
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':react-native-customized-image-picker')
compile project(':react-native-vector-icons')
compile project(':react-native-restart')
compile project(':react-native-image-picker')
compile project(':react-native-fast-image')
compile project(':lottie-react-native')
compile project(':react-native-fetch-blob')
compile "com.android.support:multidex:1.0.1"
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.fresco:fresco:1.0.1"
compile "com.facebook.fresco:animated-gif:1.0.1"
compile("com.facebook.react:react-native:0.54.0") { force = true } // From node_modules
}
I deleted some duplicate compiles that I found and still no help. I noticed in the trace this warning:
C:\ReactProjects\myapp\android\app\src\main\AndroidManifest.xml:11:5-29:19 Warning:
application#android:theme was tagged at AndroidManifest.xml:11 to replace other declarations but no other declaration present
C:\ReactProjects\myapp\android\app\src\main\AndroidManifest.xml:16:9-19:35 Warning:
meta-data#com.bumptech.glide.integration.okhttp.OkHttpGlideModule was tagged at AndroidManifest.xml:16 to remove other declarations but no other declaration present
I don't know if that will cause this whole thing to fail. Lastly here is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:allowBackup="true"
tools:replace="android:theme"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
Every problem that I had when trying to get a successful build I looked on SO or other sources, but this one takes the cake. I never inserted compile "com.android.support:multidex:1.0.1" before and it worked before this problem occurred. Still no success.
The last thing I remembered doing is saving a file called 'safecode.js' in the home directory and basically it just has code that I want to save.
I had the exact same problem and I understand what a headache this can be. Here was my solution:
1) Make sure there are no duplicate dependencies in build.gradle and settings.gradle
2) Most of you might not like this one, but I (hurts to type this) upgraded most things such as:
compileSdkVersion 26 - build.gradle
buildToolsVersion "26.0.1" - build.gradle
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip - settings.gradle
classpath 'com.android.tools.build:gradle:3.1.0' - build.gradle not in app directory
NOTE: Your Command Prompt's build UI will change and it does look overwhelming, but pretty cool. You'll get used to it. Also, you might need to change those compile in build.gradle soon.
Here is the solution for that: Android Studio build.gradle warning message
That should be pretty much it, but I'll also tell you other things I did that might affect your BUILD FAILED:
1) You might need Java 8. JDK 1.8. Add this to build.gradle app directory:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
2) Get rid of compile "com.android.support:multidex:1.0.1"
3) targetSdkVersion 22 update to 26
And lastly,
4) In build.gradle not in app directory, put maven { url 'https://maven.google.com' } in both repos.
NOTE: You could use google() in place of that, but it didn't work for me so I stuck with maven { url 'https://maven.google.com' }.
ALSO TO NOTE: You might get messages saying, "WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.". Hey, 26 seems to be our magic number, if it works, then don't touch it. Unless you are absolutely certain you need to.
To my knowledge and experience the warnings you get from the build process won't affect your BUILD SUCCESS or BUILD FAILED.
I hope this works for everyone!

Manifest merger showing implied permissions why?

I recently upgraded to android studio 3.1 and when i build out my project as a signed release the google play console tells me that there are 3 new permissions which i did not add to my manifest.
I then checked the manifest merger report and saw the following explaination:
uses-permission#android.permission.WRITE_EXTERNAL_STORAGE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license has a targetSdkVersion < 4
uses-permission#android.permission.READ_PHONE_STATE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license has a targetSdkVersion < 4
uses-permission#android.permission.READ_EXTERNAL_STORAGE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license requested WRITE_EXTERNAL_STORAGE
What does this mean , why is it saying the license class has a targetSdkVersion less then 4 ?
here are my gradle dependency versions:
firebase_version = '12.0.1'
supportlib_version = '27.0.2'
room_version = '1.0.0'
espresso_version = '3.0.1'
archLifecycleVersion = '1.1.1'
and here are my minimum sdks:
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
applicationId "com.mobile.myapp"
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
i did check the release notes for google api and saw that firebase was updated to 12.0.1 but im already using that. My goal is i do not want these permissions if they are not needed by google. i dont want to include these permission if its just for a license file ? any ideas ? i also do not know what an implied permission is. but let me show you my actual permissions in my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mobile.myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<!-- firebase analytics needs to hold a wake lock -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- hotline io uses record audio dangerous permission, we will remove it here -->
<uses-permission
android:name="android.permission.RECORD_AUDIO"
tools:node="remove" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
//...
UPDATE:
here is my google play services version:
<integer name="google_play_services_version">12211000</integer>
and i have two google play services components i use here they are:
// Analytics
implementation "com.google.android.gms:play-services-analytics:$firebase_version"
implementation("com.google.android.gms:play-services-auth:$firebase_version") {
force = true
}
WHERE firebase_version = '12.0.1' IS THE LATEST.
and here are the top level dependencies:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.25.1'
classpath "com.newrelic.agent.android:agent-gradle-plugin:5.+"
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
}
The following steps rectified the issue:
update gradle wrapper to latest 4.6
then create the following dependency resolution strategy that forces all libraries to comply with latest version (at this time) of google play libraries:
subprojects {
//todo change this to loop once
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$supportlib_version"
}
else if(details.requested.group == 'com.google.android.gms'){
details.useVersion(firebase_version) //this is critical to resolve the error
}
}
resolutionStrategy {
forcedModules = [
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
"org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
]
}
}
}
Upgrade your Google Play Services to 12.0.1
In its release notes (https://developers.google.com/android/guides/releases) you can find the following:
Adds missing minSdkVersion in -license artifacts to prevent automatic
inclusion of READ_PHONE_STATE and READ_EXTERNAL_STORAGE permissions.

Create library of my android project to use another project using android studio 2.1.2

I want to create a library of my own project which include java source code, resources (manifest, layout) file and I'm using Android Studio 2.1.2. Please give me any suggestions how I can create that one and also following one -
1) Want to create .jar library not .AAR.
2) How to add another library or any dependencies in to it, is it possible??
Thanks in advance.
see these tutorials...
How to make a .jar out from an Android Studio project
http://www.technetexperts.com/mobile/export-jar-file-from-android-studio-project/
You just need to change in your app's build.gradle file
search line
apply plugin: 'com.android.application'
and change it to
apply plugin: 'com.android.library'
and most important thing remove line
applicationId "your_package_name"
from the defaultConfig block. because libraries do not have application Id. and then build your project you'll find 'aar' folder inside you build folder.
projectfolder -> build -> output -> aar -> library_file
Edited :
and for Jar file please go through with the below command
Run gradlew makeJar command from your project root.
build.gradle file
build.gradle file apply plugin: 'com.android.library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
publishNonDefault true
defaultConfig {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
//Path to your source code
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/../lib'
}
}
}
// This is important, it will run lint checks but won't abort build
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/AdvancedWebView.jar')
compile project(':ShortcutBadger')
compile files('libs/commons-net-3.4.jar')
compile files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
}
task clearJar(type: Delete) {
delete 'release/' + POM_ARTIFACT_ID + '_' + VERSION_NAME + '.jar'
}
task makeJar(type: Copy) {
from('build/intermediates/bundles/debug/')
into('release/')
include('classes.jar')
rename ('classes.jar', POM_ARTIFACT_ID + '_' + VERSION_NAME + '.jar')
}
makeJar.dependsOn(clearJar, build)
and this is my mainifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="package name">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:label="#string/app_name"
android:supportsRtl="true">
<activity android:name=".SplashScreen"
android:label="#string/app_name"/>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:label="#string/app_name" >
</activity>
<activity android:name=".NextActivity"
android:label="#string/app_name"/>
</application>
</manifest>

Gradle doesn't pick up meta-data correctly from AndroidManifest.xml when using integration testing

Quick summary: I am trying to do integration testing using gradlew connectedAndroidTest on Android Studio 1.2.2 but I get the following error:
Position 28:28-65 : No resource found that matches the given name (at 'value' with value '#integer/google_play_services_version').
Position 31:28-51 : No resource found that matches the given name (at 'value' with value '#string/google_maps_key').
Full story:
I have two different AndroidManifest.xml, one for release and one for integration/instrumentation testing.
I execute my instrumentation tests using:
gradlew connectedAndroidTest
This uses AndroidManifest.xml located at .../src/androidTest/ and builds and runs the android tests. It looks like this:
<uses-sdk android:targetSdkVersion="22" android:minSdkVersion="15"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
<uses-library android:name="android.test.runner"/>
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:label="Tests for com.company.app"
android:functionalTest="false"
android:handleProfiling="false"
android:targetPackage="com.company.app"/>
</manifest>
When I run the app by itself (not the integration testing bit) it works properly, i.e. it picks up the google play version and the google maps key. However, I get the above error when I do integration testing using the above AndroidManifest.xml.
It has got something to do with gradle using the above given AndroidManifest.xml to generate another one, but in doing so it doesn't pick up the value of "#integer/google_play_services_version" but rather just uses it as a literal.
Any help would be much appreciated.
Thanks
EDIT
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.minttea.halalit"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.google.android.gms:play-services:6.+'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.0.8-beta'
testCompile 'org.json:json:20141113'
androidTestCompile 'junit:junit:4.12'
}
I guess it's because it's trying to find these resources in the test resources. As a quick solution, try creating res folder under androidTest/ and duplicating the requested resources there.

From Eclipse to android studio internet problems

So,I am importing a project that works perfectly (tested on 4 phones) from Eclipse to Android studio and when I run the application WITHOUT modifying anything at all, it won't allow me to use the internet at all.
As for code...it's pointless to post any ,because I created an application that does nothing but connect to a database and it still won't work, while the exact same code will work perfectly when I run the application from Eclipse to my phone. (Same phone by the way)
Just to make sure that won't be an answer: I HAVE the permissions added in my manifest.
Any suggestions?
//manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="vlad.tests.com.udptextconnection" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
// Build.gradle (module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "vlad.tests.com.udptextconnection"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
//Build.gradle (project [project-name])
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Try putting permissions outside of application tag.
Not sure if it'd work but, try and clean your project.
Go to Build->Clean Project.
Try Build->Rebuild Project.

Categories

Resources