How to configure map in my App? - android

I am trying to configure maps in my app but i am getting a fatal exception. I have obtained the google API key and added it to the manifest file.
My XML file layout is:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.aadesh.maps.MainActivity">
<com.google.android.gms.maps.MapFragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="201dp"
android:id="#+id/mapFragment" />
There was also some rendering problems in the layout.
The main activity is:
public class MainActivity extends FragmentActivity implements OnMapReadyCallback {
GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapFragment);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
//add a marker and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
Here is my logcat error:
FATAL EXCEPTION: main
Process: com.example.aadesh.maps, PID: 6677
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aadesh.maps/com.example.aadesh.maps.MainActivity}: android.view.InflateException: Binary XML file line #13: Class is not a View com.google.android.gms.maps.MapFragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
at android.app.ActivityThread.access$900(ActivityThread.java:166)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #13: Class is not a View com.google.android.gms.maps.MapFragment
at android.view.LayoutInflater.createView(LayoutInflater.java:617)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)
at android.app.Activity.setContentView(Activity.java:2009)
at com.example.aadesh.maps.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5322)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391) 
at android.app.ActivityThread.access$900(ActivityThread.java:166) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5511) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.view.View
at java.lang.Class.asSubclass(Class.java:1259)
at android.view.LayoutInflater.createView(LayoutInflater.java:565)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366) 
at android.app.Activity.setContentView(Activity.java:2009) 
at com.example.aadesh.maps.MainActivity.onCreate(MainActivity.java:21) 
at android.app.Activity.performCreate(Activity.java:5322) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391) 
at android.app.ActivityThread.access$900(ActivityThread.java:166) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5511) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
What could be the problem and how do i solve this?
Here is the gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.aadesh.maps"
minSdkVersion 14
targetSdkVersion 24
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:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-maps:9.8.00'
}

Please use fragment instead of MapFragment Class in XML file. Change as below code
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="201dp"
android:id="#+id/mapFragment" />

Related

Error inflating class com.google.android.gms.common.SignInButton

I have a button of Google Sign-in, and I don't know how fix it :(
the error is when pass setContentView(R.layout.activity_login); the class is a Activity and implements this:
public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<Cursor>, Responser<User>,
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener
I don't know where is the error, but after it was okay :(, could somebody help me please?
This is the Gradles
app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "es.iesnervion.qa"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//AÑADIDO PARA JAVA 8
jackOptions {
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
buildTypes {
lease {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:25.1.0'
//For CardViews and RecyclerViews
//Retrofit
//For animations
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.github.lzyzsd:circleprogress:1.2.1'
compile 'org.apache.ant:ant:1.7.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'org.testng:testng:6.9.6'
testCompile 'junit:junit:4.12'
compile project(path: ':libraries:BaseGameUtils')
}
BaseGameUtils
apply plugin: 'com.android.library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
}
dependencies {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('appcompat_library_version')) {
ext.appcompat_library_version = '20.0.+'
}
if (!project.hasProperty('support_library_version')) {
ext.support_library_version = '20.0.+'
}
if (!project.hasProperty('gms_library_version')) {
ext.gms_library_version = '8.4.0'
}
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile "com.google.android.gms:play-services-games:${gms_library_version}"
compile "com.google.android.gms:play-services-auth:${gms_library_version}"
compile "com.google.android.gms:play-services-plus:${gms_library_version}"
}
android {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('android_compile_version')) {
ext.android_compile_version = 23
}
if (!project.hasProperty('android_min_version')) {
ext.android_min_version = 15
}
if (!project.hasProperty('android_version')) {
ext.build_tools_version = "23.0.2"
}
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('android_min_sdk_version')) {
ext.android_min_sdk_version = 9
}
compileSdkVersion android_compile_version
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion android_min_version
targetSdkVersion android_compile_version
}
}
Activity login
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/loginId"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center_horizontal"
android:noHistory="true"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#color/colorBackground"
tools:context="es.iesnervion.qa.ui.View.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<LinearLayout
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/logo"
android:maxHeight="200dp"
android:src="#drawable/logo_big"
android:adjustViewBounds="true"
android:layout_gravity="center"/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/prueba">
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:minLines="1" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_password"
android:imeActionId="#+id/login"
android:imeActionLabel="#string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:minLines="1" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:layout_marginTop="16dp"
android:text="#string/action_sign_in"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Ó"
android:textColor="#color/colorPrimary"
android:textAlignment="center" />
<!-- sign-in button -->
<com.google.android.gms.common.SignInButton
android:id="#+id/google_sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
This is the trace:
FATAL EXCEPTION: main
Process: es.iesnervion.qa, PID: 5133
java.lang.RuntimeException: Unable to start activity ComponentInfo{es.iesnervion.qa/es.iesnervion.qa.ui.View.LoginActivity}: android.view.InflateException: Binary XML file line #101: Binary XML file line #101: Error inflating class com.google.android.gms.common.SignInButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #101: Binary XML file line #101: Error inflating class com.google.android.gms.common.SignInButton
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
at es.iesnervion.qa.ui.View.LoginActivity.onCreate(LoginActivity.java:116)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: android.view.InflateException: Binary XML file line #101: Error inflating class com.google.android.gms.common.SignInButton
at android.view.LayoutInflater.createView(LayoutInflater.java:657)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 
at es.iesnervion.qa.ui.View.LoginActivity.onCreate(LoginActivity.java:116) 
at android.app.Activity.performCreate(Activity.java:6876) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:527) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 
at es.iesnervion.qa.ui.View.LoginActivity.onCreate(LoginActivity.java:116) 
at android.app.Activity.performCreate(Activity.java:6876) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.NoSuchMethodError: No static method zzac(Ljava/lang/Object;)Lcom/google/android/gms/dynamic/zzd; in class Lcom/google/android/gms/dynamic/zze; or its super classes (declaration of 'com.google.android.gms.dynamic.zze' appears in /data/app/es.iesnervion.qa-1/base.apk)
at com.google.android.gms.common.internal.zzae.zzc(Unknown Source)
at com.google.android.gms.common.internal.zzae.zzb(Unknown Source)
at com.google.android.gms.common.SignInButton.zzbw(Unknown Source)
at com.google.android.gms.common.SignInButton.setStyle(Unknown Source)
at com.google.android.gms.common.SignInButton.<init>(Unknown Source)
at com.google.android.gms.common.SignInButton.<init>(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at android.view.LayoutInflater.createView(LayoutInflater.java:631) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:527) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 
at es.iesnervion.qa.ui.View.LoginActivity.onCreate(LoginActivity.java:116) 
at android.app.Activity.performCreate(Activity.java:6876) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Ensure that Google's Maven repository is included in your project's top-level build.gradle file:
allprojects {
repositories {
google()
// If you're using a version of Gradle lower than 4.1, you must instead use:
// maven {
// url 'https://maven.google.com'
// }
}
}
Then declare Google Play services as a dependency, in your app-level build.gradle file:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services-auth:11.8.0'
}
**PS:**Avoid declaring multiple versions of play services dependencies, this can cause mismatches and consequently generate the bug you're facing.
Just include compile 'com.google.android.gms:play-services:11.0.4' dependency in your build.gradle(app).
You must include implementation 'com.google.android.gms:play-services-auth:17.0.0' for google sign in. Because the google-sign in button is used for Google sign purpose. So you should include the dependency for it in your gradle file(app)

SearchView Issue

I am having android.support.v7.widget.SearchView in an xml but everytime i run my app , it showing me an error below .
I am unable to figure out the issue .
Xml with searchview:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="vertical"
android:id="#+id/contact_layout"
android:background="#color/green_top_bar"
android:gravity="center">
<TextView
android:id="#+id/contact_headlineText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contacts"
android:textColor="#ffffff"
android:layout_centerInParent="true"
android:textSize="24dp"
android:textStyle="bold"
/>
<android.support.v7.widget.SearchView
android:id="#+id/searchview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
app:iconifiedByDefault="false"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/contact_layout"
android:id="#+id/recyclerview"
android:visibility="gone"
android:padding="5dp"/>
<ProgressBar
android:id="#+id/progress_bar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"/>
</RelativeLayout>
Gradle file:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion "23.0.3"
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
defaultConfig {
applicationId "com.timemap"
minSdkVersion 15
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'dev.dworks.libs:volleyplus:+'
compile files('libs/httpmime-4.1-beta1.jar')
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile files('libs/gcm.jar')
}
Activity.class(error occur while loading this)
public class Contacts_new extends ActivityGroup {
#BindView(R.id.contact_headlineText)
TextView title;
#BindView(R.id.searchview)
SearchView searchView;
#BindView(R.id.recyclerview)
RecyclerView recyclerView;
#BindView(R.id.progress_bar)
ProgressBar progressBar;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contact1);
ButterKnife.bind(this);
}
}
}
Error :
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.timemap/com.timemap.rendezvous.contacts.Contacts_new}: android.view.InflateException: Binary XML file line #28: Error inflating class android.support.v7.widget.SearchView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2201)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:761)
at android.widget.TabHost.setCurrentTab(TabHost.java:425)
at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:156)
at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:741)
at android.view.View.performClick(View.java:4654)
at android.view.View$PerformClick.run(View.java:19438)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #28: Error inflating class android.support.v7.widget.SearchView
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)
at android.app.Activity.setContentView(Activity.java:2031)
at com.timemap.rendezvous.contacts.Contacts_new.onCreate(Contacts_new.java:43)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2201) 
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135) 
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347) 
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:761) 
at android.widget.TabHost.setCurrentTab(TabHost.java:425) 
at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:156) 
at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:741) 
at android.view.View.performClick(View.java:4654) 
at android.view.View$PerformClick.run(View.java:19438) 
at android.os.Handler.handleCallback(Handler.java:733) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366) 
at android.app.Activity.setContentView(Activity.java:2031) 
at com.timemap.rendezvous.contacts.Contacts_new.onCreate(Contacts_new.java:43) 
at android.app.Activity.performCreate(Activity.java:5451) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377) 
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2201) 
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135) 
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347) 
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:761) 
at android.widget.TabHost.setCurrentTab(TabHost.java:425) 
at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:156) 
at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:741) 
at android.view.View.performClick(View.java:4654) 
at android.view.View$PerformClick.run(View.java:19438) 
at android.os.Handler.handleCallback(Handler.java:733) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.view.InflateException: Binary XML file line #97: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.support.v7.widget.SearchView.<init>(SearchView.java:289)
at android.support.v7.widget.SearchView.<init>(SearchView.java:275)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
at android.view.LayoutInflater.createView(LayoutInflater.java:600) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366) 
at android.app.Activity.setContentView(Activity.java:2031) 
at com.timemap.rendezvous.contacts.Contacts_new.onCreate(Contacts_new.java:43) 
at android.app.Activity.performCreate(Activity.java:5451) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377) 
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2201) 
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135) 
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347) 
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:761) 
at android.widget.TabHost.setCurrentTab(TabHost.java:425) 
at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:156) 
at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:741) 
at android.view.View.performClick(View.java:4654) 
at android.view.View$PerformClick.run(View.java:19438) 
at android.os.Handler.handleCallback(Handler.java:733) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
at android.support.v7.widget.SearchView.<init>(SearchView.java:289) 
at android.support.v7.widget.SearchView.<init>(SearchView.java:275) 
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
at android.view.LayoutInflater.createView(LayoutInflater.java:600) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366) 
at android.app.Activity.setContentView(Activity.java:2031) 
at com.timemap.rendezvous.contacts.Contacts_new.onCreate(Contacts_new.java:43) 
at android.app.Activity.performCreate(Activity.java:5451) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377) 
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2201) 
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135) 
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347) 
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:761) 
at android.widget.TabHost.setCurrentTab(TabHost.java:425) 
at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:156) 
at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:741) 
at android.view.View.performClick(View.java:4654) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f0100e6 a=-1}
at android.content.res.Resources.loadDrawable(Resources.java:3394)
at an

Using additional library

I am trying to use a custom calendar. (show it through xml-markup). But the app crash. What could be the reason? All I have done as it is written here. Made by Gradle manually inserting build.gradle. I have the same problem with other similar libraries, have already tried to use 5-6 libraries.
xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.denis.myplans.NewNoteActivity">
<com.imanoweb.calendarview.CustomCalendarView
android:id="#+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"/>
</RelativeLayout>
from error log:
03-28 21:30:36.222 7338-7338/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.denis.myplans, PID: 7338
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.denis.myplans/com.example.denis.myplans.MainActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class com.imanoweb.calendarview.CustomCalendarView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2521)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class com.imanoweb.calendarview.CustomCalendarView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.denis.myplans.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:6112)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
at android.app.ActivityThread.main(ActivityThread.java:5637) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:802) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at com.example.denis.myplans.MainActivity.onCreate(MainActivity.java:19) 
at android.app.Activity.performCreate(Activity.java:6112) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
at android.app.ActivityThread.main(ActivityThread.java:5637) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
Caused by: java.lang.StringIndexOutOfBoundsException: length=2; regionStart=0; regionLength=3
at java.lang.String.startEndAndLength(String.java:504)
at java.lang.String.substring(String.java:1333)
at com.imanoweb.calendarview.CustomCalendarView.initializeWeekLayout(CustomCalendarView.java:171)
at com.imanoweb.calendarview.CustomCalendarView.refreshCalendar(CustomCalendarView.java:356)
at com.imanoweb.calendarview.CustomCalendarView.initializeCalendar(CustomCalendarView.java:132)
at com.imanoweb.calendarview.CustomCalendarView.<init>(CustomCalendarView.java:74)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:802) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at com.example.denis.myplans.MainActivity.onCreate(MainActivity.java:19) 
at android.app.Activity.performCreate(Activity.java:6112) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
at android.app.ActivityThread.main(ActivityThread.java:5637) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372)
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.denis.myplans"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.github.npanigrahy:Custom-Calendar-View:v1.0'
}
MainActivity.java
package com.example.denis.myplans;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final Intent intNewNote = new Intent(this, NewNoteActivity.class);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
assert fab != null;
fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
startActivity(intNewNote);
}
});
}
For use this library you need read how can implement, first need add on your build.gradle the Jitpack repository.
After
apply plugin: 'com.android.application'
you should add this
repositories {
maven { url "https://jitpack.io" }
}
On your Maven repository and dependency needs look like this.
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.npanigrahy</groupId>
<artifactId>Custom-Calendar-View</artifactId>
<version>v1.0</version>
</dependency>
After that it should Works.

Android View InflateException when using ViewPager

I am trying to use MapFragment in ViewPager. Although I defined FragmentManager as SupportFragmentManager, if I slide to the page contains MapFragment, I see InflateException. I read most of the titles mentioned this issue but cannot see a solution yet. I hope you can. Here is the layout of my MapFragment class:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="7dp"
android:orientation="vertical"
android:gravity="left">
<ImageButton
android:id="#+id/searchButton"
android:background="#drawable/search_button"
android:layout_marginTop="10dp"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentTop="true"/>
<ImageButton
android:id="#+id/originButton"
android:background="#drawable/origin_button"
android:layout_marginBottom="10dp"
android:layout_marginRight="7dp"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true"/>
<ImageButton
android:id="#+id/earthButton"
android:background="#drawable/earth_button"
android:layout_marginBottom="10dp"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#id/originButton"/>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginRight="14dp"
android:orientation="vertical"
android:gravity="right" >
<ImageButton
android:id="#+id/plusButton"
android:background="#drawable/plus_button"
android:layout_centerInParent="true"
android:layout_width="50dip"
android:layout_height="50dip"/>
<View
android:layout_width="0dp"
android:layout_height="7dp"
android:layout_weight="1"/>
<ImageButton
android:id="#+id/minusButton"
android:background="#drawable/minus_button"
android:layout_centerInParent="true"
android:layout_width="50dip"
android:layout_height="50dip"/>
</LinearLayout>
</RelativeLayout>
The log:
Process: net.geotune.app, PID: 17582
android.view.InflateException: Binary XML file line #8: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at net.geotune.app.dorukhan.MapFragment.onCreateView(MapFragment.java:177)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1302)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:729)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:555)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:514)
at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:495)
at net.geotune.app.main.MainPager.onTabSelected(MainPager.java:95)
at com.android.internal.app.ActionBarImpl.selectTab(ActionBarImpl.java:578)
at com.android.internal.app.ActionBarImpl$TabImpl.select(ActionBarImpl.java:1108)
at com.android.internal.widget.ScrollingTabContainerView$TabClickListener.onClick(ScrollingTabContainerView.java:556)
at android.view.View.performClick(View.java:4478)
at android.view.View$PerformClick.run(View.java:18698)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5268)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Binary XML file line #8: Duplicate id 0x7f090093, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2164)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory.onCreateView(CalligraphyLayoutInflater.java:249)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:163)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at net.geotune.app.dorukhan.MapFragment.onCreateView(MapFragment.java:177)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
            at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1302)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:729)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
            at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
            at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
            at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:555)
            at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:514)
            at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:495)
            at net.geotune.app.main.MainPager.onTabSelected(MainPager.java:95)
            at com.android.internal.app.ActionBarImpl.selectTab(ActionBarImpl.java:578)
            at com.android.internal.app.ActionBarImpl$TabImpl.select(ActionBarImpl.java:1108)
            at com.android.internal.widget.ScrollingTabContainerView$TabClickListener.onClick(ScrollingTabContainerView.java:556)
            at android.view.View.performClick(View.java:4478)
            at android.view.View$PerformClick.run(View.java:18698)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:149)
            at android.app.ActivityThread.main(ActivityThread.java:5268)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
            at dalvik.system.NativeStart.main(Native Method)
I got the error in the following segment of ViewPager's class:
#Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
viewPager.setCurrentItem(tab.getPosition());
}
Lastly, build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
defaultConfig {
applicationId 'net.geotune.app'
minSdkVersion 19
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.spotify.sdk:spotify-player:1.0.0-beta9#aar'
compile 'com.spotify.sdk:spotify-auth:1.0.0-beta9#aar'
compile files('libs/Android/android-async-http-1.3.1.jar')
compile files('libs/Android/jackson-core-asl-1.8.5.jar')
compile files('libs/Android/jackson-mapper-asl-1.8.5.jar')
compile files('libs/Android/KumulosAndroid.0.2.3.jar')
compile files('libs/spotify-web-api-android-0.1.0.jar')
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile group: 'io.orchestrate', name: 'orchestrate-client', version: '0.9.0'
compile 'uk.co.chrisjenx:calligraphy:2.0.2'
compile 'com.sothree.slidinguppanel:library:3.0.0'
}
I know I added too much code above, I am sorry for that. I just want to leave no stone unturned.
There is not problem with neither gradle nor layout file. MapFragment's onCreateView() should be set as follows:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (container == null)
return null;
if (v != null) {
ViewGroup parent = (ViewGroup) v.getParent();
if (parent != null)
parent.removeView(v);
}
try {
v = inflater.inflate(R.layout.fragment_map, container, false);
} catch (InflateException e) { }
mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
if (mapFragment != null) {
mapFragment.onCreate(savedInstanceState);
mapFragment.onResume();
try {
MapsInitializer.initialize(getActivity().getApplicationContext());
} catch (Exception e) {
e.printStackTrace();
}
googleMap = mapFragment.getMap();
// Do whatever you want on map here
}
return v;
}
This problem is thoroughly discussed in this question. Thus, I did not explain the code segment in detail.

Lollipop throwing Incorrect Signature for SupportMapFragment

I have an android app that shows a map via a SupportMapFragment. The app was running fine for the past several months until just recently I upgraded my phone from 4.4.4 to 5.0 (via the official OTA update). Now the app crashes and I get the following stack trace:
11-18 12:51:49.699 12594-12594/com.foo.bar E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.foo.bar, PID: 12594
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.foo.bar/com.foo.bar.CallActivity}: android.view.InflateException: Binary XML file line #89: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #89: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Activity.setContentView(Activity.java:2144)
at com.foo.bar.CallActivity.onCreate(CallActivity.java:89)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.SecurityException: Incorrect signature
at org.apache.harmony.security.utils.JarUtils.verifySignature(JarUtils.java:223)
at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:294)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:268)
at java.util.jar.JarFile.getInputStream(JarFile.java:380)
at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
at java.net.URL.openStream(URL.java:470)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:444)
at java.lang.Class.getResourceAsStream(Class.java:1334)
at com.google.l.a.a.a.a(Unknown Source)
at com.google.l.a.a.a.a(Unknown Source)
at com.google.maps.api.android.lib6.b.e.<init>(Unknown Source)
at com.google.maps.api.android.lib6.b.e.<init>(Unknown Source)
at com.google.maps.api.android.lib6.b.e.a(Unknown Source)
at com.google.maps.api.android.lib6.c.dm.a(Unknown Source)
at com.google.maps.api.android.lib6.c.dw.a(Unknown Source)
at com.google.maps.api.android.lib6.c.v.a(Unknown Source)
at com.google.maps.api.android.lib6.c.u.a(Unknown Source)
at com.google.android.gms.maps.internal.u.onTransact(SourceFile:107)
at android.os.Binder.transact(Binder.java:380)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
at com.google.android.gms.dynamic.a$4.b(Unknown Source)
at com.google.android.gms.dynamic.a.a(Unknown Source)
at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:920)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1206)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2159)
at android.support.v4.app.FragmentActivity.onCreateVie
Here is my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/myLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".CallActivity"
android:orientation="vertical"
android:background="#FFFFFF" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
here's my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.foo.bar"
minSdkVersion 9
targetSdkVersion 21
versionCode 126
versionName "1.0.126"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:21.0.+'
compile 'com.google.android.gms:play-services:6.1.71'
compile fileTree(dir: 'libs', include: '*.jar')
}
and here is the relevant bits of the activity:
public class CallActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call); // this is line 89 (the line referenced in the stack trace)
...
The same app still works fine on another phone with an older version of android. And if I remove the fragment from the layout, it runs without crashing on my phone with 5.0 (of course without the map), so I'm fairly certain it's the map fragment that's causing the issue.
Has anyone else seen anything like this? Any ideas of what to try?
Try to change
static {
Security.addProvider(new BouncyCastleProvider());
}
with
static {
Security.insertProviderAt(new BouncyCastleProvider(), 1);
}
See also
https://github.com/rtyley/spongycastle-old/issues/10
I figured it out. It was related to spongycastle. I had the following in my application class:
static {
Security.addProvider(new BouncyCastleProvider());
}
As soon as I commented out that block, it started working.
Remove BouncyCastle/SpongyCastle provider when Google Map view is created.
Then add it again when Google Map view is destroyed.
Create fragment inherited from SupportMapFragment.
Override onCreateView and onDestroyView.
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (Build.VERSION.RELEASE.equals("5.0"))
{
Security.removeProvider("SC");
}
return super.onCreateView(inflater, container, savedInstanceState);
}
#Override
public void onDestroyView() {
if (Build.VERSION.RELEASE.equals("5.0"))
{
Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());
}
super.onDestroyView();
}
Use this inherited fragment instead of SuuportMapFragment in layout xml.

Categories

Resources