Cannot resolve symbol 'maps' - java

I imported mixare source code to Android Studio 3.1 but I get error message Cannot resolve symbol 'maps' in following lines:
import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import com.google.android.maps.Projection;
I saw this page but none of the answers were helpful. How can I fix this?
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'org.mixare'
minSdkVersion 14
targetSdkVersion 24
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
implementation project(':mixarelib')
implementation 'com.google.android.gms:play-services-maps:12.0.0'
}
AndroidManifest.xml:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
tools:ignore="AllowBackup"
tools:replace="android:label">
<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="(API KEY)" />
<uses-library android:name="com.google.android.maps" />
...

I solved this very easily.
Go to Settings | Appearance & Behavior | Android SDK and check 'Show Package Details'.
Select SDK version(I selected 7.0), check 'Google APIs' and install it. I don't know why the option doesn't exist in the version 7.1.1 and over.
And configure build.gradle like this:
compileSdkVersion 'Google Inc.:Google APIs:24'

Related

Can we implement multiple Content Providers to WhatsApp stickers app?

As my requirements are my app has the functionality of creating Custom Stickers and Stickers From Server a Single Content Provider causing issues, I tried a lot adding multiple Content Providers it's causing issues in Edit configuration
As seen below
This is how I am trying to add providers in manifest
<provider
android:name=".whats_app_based_code.provider.StickerContentProvider"
android:authorities="${contentProviderAuthority}"
android:enabled="true"
android:exported="true"
android:readPermission="com.whatsapp.sticker.READ">
</provider>
<provider
android:name=".whats_app_based_code.provider.StickerContentProviderServer"
android:authorities="${contentProviderAuthority}"
android:enabled="true"
android:exported="true"
android:readPermission="com.whatsapp.sticker.READ">
</provider>
App Level Gradle
android {
compileSdkVersion 30
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.numan.stickersapp"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
def contentProviderAuthority = applicationId + ".WhatsAppLicensedCode.StickerContentProvider"
def contentProviderAuthority2 =applicationId+".WhatsAppLicensedCode.StickerContentProviderServer"
// Creates a placeholder property to use in the manifest.
manifestPlaceholders = [contentProviderAuthority: "\"${contentProviderAuthority}\""]
manifestPlaceholders = [contentProviderAuthorityserver: "\"${contentProviderAuthority2}\""]
// Adds a new field for the authority to the BuildConfig class.
buildConfigField("String", "CONTENT_PROVIDER_AUTHORITY", "\"${contentProviderAuthority}\"")
buildConfigField("String","CONTENT_PROVIDER_AUTHORITY_SERVER","\"${contentProviderAuthority2}\"")
buildConfigField 'String', 'STICKERS_BASE_URL', "\"https://firebasestorage.googleapis.com/\""
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Finally, I did this part I am adding my approach to achieve this because Someone like me may want to add such functionality to their app:
What I actually did is:
I only added a single content provider in App Level Gradle and removed the other one
I added the second content provider through manifest and hardcoded the complete provider package like this:
<provider
android:name=".whats_app_based_code.provider.StickerContentProvider"
android:authorities="${contentProviderAuthority}"
android:enabled="true"
android:exported="true"
android:readPermission="com.whatsapp.sticker.READ">
</provider>
<provider
android:name=".whats_app_based_code.provider.StickerContentProviderServer"
android:authorities="com.numan.stickersapp.whats_app_based_code.provider.WhatsAppLicensedCode.StickerContentProviderServer"
android:enabled="true"
android:exported="true"
android:readPermission="com.whatsapp.sticker.READ">
</provider>

Need solution for "Manifest merger failed with multiple errors"

I trying to user multiple module android project to work on my application and when I try to build the project. the project build fails with Manifest merge failures. I need help to resolve this issue.
I already tried changing the dependencies in Gradle files and tried rearranging them, searched other solutions in this and here as well, but none of them helped
my AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.atomnest.chitfund">
<application
xmlns:tools="http://schemas.android.com/tools"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory" />
</manifest>
since the project is not build successfully I'm not able to add any activity to the project
and my build.gradle File
apply plugin: 'com.android.application'
buildscript {
ext {
support_version = '1.0.2'
}
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.atomnest.chitfund"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation "androidx.appcompat:appcompat:$support_version"
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.firebase:geofire-android:2.1.1'
implementation project(':utility')
implementation project(':library')
}
I am expecting to get the project build successfully and be able to launch the app in the emulator. pls help
here is the logcat image
If you are using androidx then you have to use all libraries compatible with androidx so you can use this code:-
In gradle.build (app) add this
compileSdkVersion 28
defaultConfig {
......
minSdkVersion 21
targetSdkVersion 28
......
}
And there are some implementations required to use androidx :-
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
And add these given two lines(below) to gradle.properties:-
android.useAndroidX=true
android.enableJetifier=true
Solution 1:
Suggestion: add 'tools:replace="android:appComponentFactory"' to
element at AndroidManifest.xml to override.
If you added the tools:replace="android:appComponentFactory" and still got trouble by fixing it, create a new project, copy-paste the codes and the same dependencies in there. After that, it should be fixed i hope.
If it didn't solve the issue, try adding these two:
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
In AndroidManifest.xml > <application tag of course.
Solution 2:
Add below two lines in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
You can also follow below link:
https://developer.android.com/jetpack/androidx/migrate
Do let me know if you get any problem.
Actually I had the same issue.In my case it was butterknife. I changed the dependency into 8.8.1 and it works fine for me.

Error when Multidex Enabled

I've recently had to enable multidex in my android studio project, this is built with imported module. It's doing well in the main project, but showing multidex problem in the project built with imported(from the main project) module. I have followed this documentation to enable multidex. As the application tag is not overridden , so i've followed the method related. Now i'm getting this error:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [E:\something\SalesDemo >Updated\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't >read [E:\something\SalesDemo >Updated\app\build\intermediates\classes\debug(;;;;;;**.class)] (Can't read [com] >(Can't read [smth] (Can't read [infolinkplus] (Can't read
[some.class] (Duplicate zip entry
[com/abc/def/some.class]))))))
Here's my build.gradle:
apply plugin: 'com.android.application'
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 25
// buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.abc.def.somethingotherthing"
multiDexEnabled true
minSdkVersion 16
//noinspection OldTargetApi
targetSdkVersion 22
versionCode 16
versionName "0.0.16"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//implementation 'com.android.support:multidex:1.0.3'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.3'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'joda-time:joda-time:2.3'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile project(':infolinkplus')
}
And the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.abc.def.somethingotherthing">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
...
//ACTIVITIES AND META-TAGS
...
</application>
</manifest>
After changes, i ran clean build and rebuilt but no result.
How can i overcome this problem? Thanks in advance.
You have to change your Manifest to provide MultiDex:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
or if you have custom Application class, you have to extend it with MultiDexApplication
public class MyApplication extends MultiDexApplication { ... }
Duplicate zip entry
[com/abc/def/some.class]
In your project you must be having a class with name some.class rename it to some thing else
Try this code...
i hope you done this things..
multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'
make class for application level..
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
}
}
android:name="MyApplication" > // here define that class name that extends by MultiDexApplication

Java code cannot access Kotlin's package since Kotlin 1.0.0 [duplicate]

After updating kotlin to RC-1036 i'm facing a weird issue: my code is not even compiled and packed.
When build passes and the app is launched i'm getting ClassNotFoundException: Didn't find class "example.myapplication.MainActivity".
I have tried to decompile apk with apktool and didn't find my classes inside the archive. There are no classes in build/intermediates dir either.
This is my project:
app/build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
buildscript {
ext.kotlin_version = '1.0.0-rc-1036'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "example.myapplication"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="example.myapplication"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
And MainActivity:
package example.myapplication
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
hello.text = "New text"
}
}
Build tools version is 2.0.0-beta2;
Might be something wrong with sourseSets, though nothing works if i try to reconfigure it somehow. Appreciate any help.
You should have both these plugins:
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
The first makes sure the Kotlin code compiles, the second is for the UI imports.

Noclassdeffounderror - Can't find v7 support (android studio)

so im trying to build an app using GCM. i've opened 2 modules for this. a backend (GCM messaging with appengine and a regular module - the names are "app" (regular module" and "backend").
i'm recieving this problem and i can't figure the solotion for it.
when the app is starting i get the following error:
10-04 18:24:16.391 18920-18920/com.example.daniel.testing6 E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$attr
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:289)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.daniel.testing6.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
My project name is Testing6 and its gradle:
// 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.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
my app module gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.example.daniel.testing6"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true // i added it because i got different problem
}
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.2.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile project(path: ':backend', configuration: 'android-endpoints')
}
and my backend module:
// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
compile 'com.google.appengine:appengine-endpoints:1.9.18'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.googlecode.objectify:objectify:4.0b3'
compile 'com.ganyo:gcm-server:1.0.2'
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
public class MainActivity extends MultiDexApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
doew anyone knows how to fix it???
Problem Solved!
Ok so i did the following:
manifast:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.daniel.testing6" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<application
android:name="com.example.daniel.testing6.Application"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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>
<activity
android:name=".Main2Activity"
android:label="#string/title_activity_main2"
android:theme="#style/AppTheme.NoActionBar" >
</activity>
</application>
</manifest>
ok so to get rid of the error i went to the gradle of my module app:
so it will look like that:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.example.daniel.testing6"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':backend', configuration: 'android-endpoints')
//
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:design:22.2.1'
}
next i created an Application as follows:
package com.example.daniel.testing6;
import android.content.Context;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
/**
* Created by Daniel on 05-Oct-15.
*/
public class Application extends MultiDexApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
and a main activity normally:
package com.example.daniel.testing6;
import android.content.Context;
import android.content.Intent;
import android.os.PersistableBundle;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startActivity(new Intent(this, Main2Activity.class));
}
}
the manifast calls the Application that uploading all its data and then moves to the activity once the data is with in our reach :)
You also have to:
Include `compile 'com.android.support:multidex:1.0.0'` in your dependencies
See https://developer.android.com/tools/building/multidex.html for more details.
Also have your Application class extend MultiDexApplication instead of just Application. Alternatively, you can call MultiDex.install() in attachBaseContext() of your application
Installing/updating Android Support Library and Android Support Repository in SDK manager will fix such errors

Categories