没有这样的方法Error Floating action按钮

时间:2016-11-16 09:14:06

标签: android floating-action-button nosuchmethoderror

在另一台计算机上安装Project。现在我得到一个"没有这样的方法错误"因为浮动操作按钮导致Activity崩溃。我尝试了几件事(主要是更新依赖关系等等),但没有任何帮助。

任何人都遇到过这个问题或者知道如何修复它?

以下是例外:

FATAL EXCEPTION: main
                                                                           java.lang.RuntimeException: Unable to start activity ComponentInfo{MapsActivity}: android.view.InflateException: Binary XML file line #27: Error inflating class android.support.design.widget.FloatingActionButton
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
                                                                               at android.app.ActivityThread.access$700(ActivityThread.java:159)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                               at android.os.Looper.loop(Looper.java:176)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5419)
                                                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                                                               at java.lang.reflect.Method.invoke(Method.java:525)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
                                                                               at dalvik.system.NativeStart.main(Native Method)
                                                                            Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class android.support.design.widget.FloatingActionButton
                                                                               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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
                                                                               at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
                                                                               at MapsActivity.onCreate(MapsActivity.java:230)
                                                                               at android.app.Activity.performCreate(Activity.java:5372)
                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) 
                                                                               at android.app.ActivityThread.access$700(ActivityThread.java:159) 
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                               at android.os.Looper.loop(Looper.java:176) 
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5419) 
                                                                               at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                               at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
                                                                               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:417)
                                                                               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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                               at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 
                                                                               at MapsActivity.onCreate(MapsActivity.java:230) 
                                                                               at android.app.Activity.performCreate(Activity.java:5372) 
                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) 
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257) 
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) 
                                                                               at android.app.ActivityThread.access$700(ActivityThread.java:159) 
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                               at android.os.Looper.loop(Looper.java:176) 
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5419) 
                                                                               at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                               at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
                                                                               at dalvik.system.NativeStart.main(Native Method) 
                                                                            Caused by: java.lang.NoSuchMethodError: android.support.v7.widget.AppCompatImageHelper.<init>
                                                                               at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:133)
                                                                               at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:110)
                                                                               at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                               at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
                                                                               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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                               at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 
                                                                               at onCreate(MapsActivity.java:230) 
                                                                               at android.app.Activity.performCreate(Activity.java:5372) 
                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) 
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257) 
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) 
                                                                               at android.app.ActivityThread.access$700(ActivityThread.java:159) 
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                               at android.os.Looper.loop(Looper.java:176) 
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5419) 
                                                                               at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                               at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
                                                                               at dalvik.system.NativeStart.main(Native Method) 

gradle-file:

apply plugin: 'com.android.application'

android {     compileSdkVersion 23     buildToolsVersion&#34; 23.0.2&#34;

defaultConfig {
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    debug {
        resValue "string", "google_maps_key", "AIzaSyDvYeaYsC6HzIcj2aYwhsq4FoKQ6N4I1tw"
    }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        resValue "string", "google_maps_key", "AIzaSyBqbhPyN2c60ViYQAD219jBMt1TkwzNxWE"
    }
}
lintOptions {
    abortOnError false
}
}

repositories {
mavenCentral()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'me.leolin:ShortcutBadger:1.1.4@aar'
}



apply plugin: 'com.google.gms.google-services'

和清单:

<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality. 
-->

<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE" />

<!-- GCM -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<!-- if you want to keep processor from sleeping when a message is received -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />



<application
    android:icon="@drawable/ic_icon"
    android:name="android.support.multidex.MultiDexApplication"
    android:largeHeap="true"
    android:screenOrientation="portrait"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id" />
    <provider
        android:name="com.facebook.FacebookContentProvider"
        android:authorities="com.facebook.app.FacebookContentProvider1496945817221747"
        android:exported="true" />
    <activity
        android:name=".SplashScreen"
        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=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar" >
    </activity>
    <activity
        android:name=".AddActivity"
        android:label="@string/title_activity_add"
        android:parentActivityName=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="MainActivity" />
    </activity>
    <activity
        android:name=".DiscoverActivity"
        android:label="@string/title_activity_discover"
        android:parentActivityName=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="MainActivity" />
    </activity>
    <activity
        android:name=".DetailActivity"
        android:label="@string/title_activity_detail"
        android:parentActivityName=".MainActivity"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    </activity>
    <activity
        android:name=".ProfileActivity"
        android:label="@string/title_activity_profile"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    </activity>
    <activity
        android:name=".EditProfileActivity"
        android:label="@string/title_activity_edit_profile"
        android:parentActivityName=".ProfileActivity"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="ProfileActivity" />
    </activity>

    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps"
        android:screenOrientation="portrait" >
    </activity>

    <!-- FACEBOOK ACTIVITY -->
    <activity
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name" />
    <activity
        android:name=".FriendsActivity"
        android:label="@string/title_activity_friends"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    </activity>
    <activity
        android:name=".RegisterActivity"
        android:label="@string/title_activity_register"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    </activity>
    <activity
        android:name=".NotificationsActivity"
        android:label="@string/title_activity_notifications"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    </activity>

    <!-- GCM -->


    <!-- [START gcm_receiver] -->
    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="gcm.play.android.samples.com.gcmquickstart" />
        </intent-filter>
    </receiver>

    <!--receiver
        android:name=".ExternalReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <action android:name="com.google.android.c2dm.intent.REGISTER" />

            <category android:name=".androidtest" />
        </intent-filter>
    </receiver-->

    <service
        android:name=".MyGcmListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>
    <service
        android:name=".MyInstanceIDListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>
    <!--service
        android:name=".MyGcmRegistrationService"
        android:exported="false" >
    </service-->

    <service
        android:name=".NotificationService"
        android:exported="false" >
    </service>
    <!-- make API to register app to GCM available -->
    <service
        android:name=".RegistrationIntentService"
        android:exported="false" >
        <intent-filter>
            <action
                android:name="com.google.android.gms.iid.InstanceID"
                android:permission="com.google.android.c2dm.permission.RECEIVE" />
        </intent-filter>
    </service>
    <service
        android:name=".LoadImageService"
        android:exported="false" >
    </service>
    <service
        android:name=".AddFriendService"
        android:exported="false" >
    </service>
    <service
        android:name=".AcceptFriendService"
        android:exported="false" >
    </service>
    <service
        android:name=".JoinService"
        android:exported="false" >
    </service>
    <service
        android:name=".DeleteService"
        android:exported="false" >
    </service>

    <activity
        android:name=".EditActivity"
        android:label="@string/title_activity_edit"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    </activity>

    <!--service
        android:name=".MessageReceivingService"
        android:label=".MessageReceivingService" >
        <intent-filter>
            <action android:name=".AndroidMobilePushApp" />
            <action android:name=".ExternalReceiver" />

            <category android:name=".androidtest" />
        </intent-filter>
    </service-->

    <activity
        android:name=".BasesActivity"
        android:label="@string/title_activity_bases"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    </activity>
    <activity
        android:name=".SettingsActivity"
        android:label="@string/title_activity_settings"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    </activity>
</application>

浮动操作按钮:

        <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_locate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:src="@drawable/icn_target"
        app:backgroundTint="@color/colorStorowBlue"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/card_view"
        android:layout_alignEnd="@+id/card_view"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="10dp"
        android:layout_alignParentRight="true" />

1 个答案:

答案 0 :(得分:1)

会发表评论,但没有足够的代表。

检查一下: InflateException with FloatingActionButton from Official Design Library

查看你的主题和compat库。