2016-09-16 24 views
5

在我的新的項目,我想從Crashlytics Fabric.io插件面料Android Studio中沒有發現進口com.crashlytics&io.fabric

整合

我已經在其他項目沒有問題,安裝布,一個項目這裏的教程:https://fabric.io/kits/android/crashlytics/install

,而另一項目,我已經使用整合到Android Studio中(圖)enter image description here

這裏的插件面料的問題:

import android.app.Application; 
import com.crashlytics.android.Crashlytics; 
import io.fabric.sdk.android.Fabric; 

public class UILApplication extends Application { 

    @Override 
    public void onCreate() { 
     super.onCreate(); 
     Fabric.with(this, new Crashlytics()); // Fabric not found 
    }  
} 


Error:(6, 31) error: package com.crashlytics.android does not exist 
Error:(7, 29) error: package io.fabric.sdk.android does not exist 
Error:(20, 31) error: cannot find symbol class Crashlytics 
Error:(20, 9) error: cannot find symbol variable Fabric 
Note: Some input files use or override a deprecated API. 
Note: Recompile with -Xlint:deprecation for details. 
:app:compileDebugJavaWithJavac FAILED 
Error:Execution failed for task ':app:compileDebugJavaWithJavac'. 
> Compilation failed; see the compiler error output for details. 

我的build.gradle(項目):

task wrapper(type: Wrapper) { 
    gradleVersion = '2.12' 
} 

的build.gradle(模塊:APP):

buildscript { 
    repositories { 
     mavenCentral() 
     maven { url "http://oss.sonatype.org/content/repositories/snapshots/" } 
     // maven { url 'https://maven.fabric.io/public' } THIS LINE FORGOTTEN 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.2' 
     classpath 'com.google.gms:google-services:3.0.0' 
     //classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 

apply plugin: "com.android.application" 
//apply plugin: 'io.fabric' 

repositories { 
    mavenCentral() 
    maven { url "http://oss.sonatype.org/content/repositories/snapshots/" } 
    // maven { url 'https://maven.fabric.io/public' } 
} 
    android { 
     compileSdkVersion = 24 
     buildToolsVersion = "23.0.3" 

     defaultConfig { 
      applicationId "agemos.testkalman1" 
      minSdkVersion 15 
      targetSdkVersion 24 
      versionCode 1 
      versionName "1.0"    
     } 

     buildTypes { 
      release { 
       minifyEnabled false 
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      } 
     } 
    } 


dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:24.2.0' 
    compile 'com.android.support:design:24.2.0' 

    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:[email protected]'){ 
     transitive=true 
    } 
// // Crashlytics Fabric io 
// compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
//  transitive = true; 
// } 

} 

我已經改變compileSdkVersion 23至24,但一切都沒有改變,有人有這個問題?

在此先感謝您的幫助:)


我已經忘了一行

現在,它的作品!對不便,請諒解^^'

+1

發佈您的根和應用程序級別的gradle文件。你必須沒有正確地遵循步驟 – NightFury

+0

classpath'com.android.tools.build:gradle:2.1.2'和Gradle Version 2.14 – bzhWarrior

+1

請發佈你在教程中遵循的構建gradle文件 – NightFury

回答

7

邁克從織物這裏。

看起來你已經在你的build.gradle中註釋了Fabric的所有初始化?如果您對下面的行進行了取消註釋,那應該可行。

classpath 'io.fabric.tools:gradle:1.+' 

apply plugin: 'io.fabric' 


maven { url 'https://maven.fabric.io/public' } 


// Crashlytics Fabric io 
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
    transitive = true; 
} 

完整的build.gradle將有all of the following changes

buildscript { 
    repositories { 
    maven { url 'https://maven.fabric.io/public' } 
    } 

    dependencies { 
    // The Fabric Gradle plugin uses an open ended version to react 
    // quickly to Android tooling updates 
    classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 

apply plugin: 'io.fabric' 

repositories { 
    maven { url 'https://maven.fabric.io/public' } 
} 



compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
    transitive = true; 
    } 
0

清晰,重建和重新啓動Android的工作室,工作

enter image description here

的build.gradle項目

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 

    repositories { 
     google() 
     jcenter() 
    } 


    buildscript { 
     repositories { 
      jcenter() 
      mavenCentral() 
      maven { url 'https://maven.fabric.io/public' } 
     } 
     dependencies { 
      classpath 'io.fabric.tools:gradle:1.+' 
     } 
    } 

    dependencies { 
     classpath 'com.android.tools.build:gradle:3.0.1' 
     classpath 'io.fabric.tools:gradle:1.+' 


     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 


allprojects { 
    repositories { 
     google() 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

的build.gradle模塊

apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 

android { 
    compileSdkVersion 26 
    defaultConfig { 
     applicationId "com.holostik.ozoneoverseas" 
     minSdkVersion 15 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

android { 
    defaultConfig { 
     multiDexEnabled true 
    } 
} 

dependencies { 
    // TODO FCM 
// implementation 'com.google.firebase:firebase-messaging:11.0.4' 
//compile 'com.google.firebase:firebase-messaging:11.0.4' 

    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:appcompat-v7:26.+' 
    compile 'com.android.support:appcompat-v7:26.0.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    testCompile 'junit:junit:4.12' 
    compile 'me.dm7.barcodescanner:zxing:1.9.7' 
    compile 'com.android.support:cardview-v7:26.0.1' 
    compile 'com.android.support:design:26.0.1' 
    compile 'com.github.bumptech.glide:glide:3.7.0' 
    compile 'de.hdodenhof:circleimageview:1.3.0' 
    compile 'com.android.volley:volley:1.0.0' 
// compile 'com.google.android.gms:play-services-location:7.8.0'  // TODO Previous working 
// compile 'com.google.android.gms:play-services-location:9.0.0' 
    compile 'com.google.android.gms:play-services-location:11.0.4' 
// compile "com.google.android.gms:play-services-gcm:9.2.0" 

    compile 'com.squareup.retrofit2:retrofit:2.1.0' 
    compile 'com.squareup.retrofit2:converter-gson:2.1.0' 
    compile 'com.android.volley:volley:1.0.0' 
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+' 
    //TODO camera Crop dependency working 
// compile files('libs/ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar') 

// implementation 'com.google.firebase:firebase-messaging:11.0.4' 

// compile 'com.google.android.gms:play-services:11.4.0' 
    compile 'com.google.android.gms:play-services:11.0.4' 

    // compile 'com.facebook.android:facebook-android-sdk:4.8.0'   // Works here 
    compile 'com.facebook.android:facebook-android-sdk:4.13.1'   // Works here 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    compile('com.crashlytics.sdk.android:crashlytics-ndk:[email protected]') { 
     transitive = true; 
    } 


    repositories { 
     maven { url 'https://maven.fabric.io/public' } 
    } 

} 

allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
} 




/*buildscript { 
    repositories { 
     maven { url 'https://maven.fabric.io/public' } 
    } 

    // ... 
    dependencies { 
     // ... 
     classpath 'com.google.gms:google-services:3.1.1' // google-services plugin 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 

allprojects { 
    // ... 
    repositories { 
     // ... 
     maven { 
      url "https://maven.google.com" // Google's Maven repository 
     } 
    } 
}*/ 
// TODO FCM 
//apply plugin: 'com.google.gms.google-services' // TODO FCM add auto in Bottom When Google Service Add uncomment this 

//dependencies { 
// implementation fileTree(dir: 'libs', include: ['*.jar']) 
// implementation 'com.android.support:appcompat-v7:26.1.0' 
// implementation 'com.android.support.constraint:constraint-layout:1.0.2' 
// testImplementation 'junit:junit:4.12' 
// androidTestImplementation 'com.android.support.test:runner:1.0.1' 
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 
//} 



crashlytics { 
    enableNdk true 
    androidNdkOut 'src/main/obj' 
    androidNdkLibsOut 'src/main/libs' 
} 

的manifest.xml

<meta-data 
     android:name="io.fabric.ApiKey" 
     android:value="1864e6d3e59158a5206d2d073e7e14c7ad811cbd" /> 

飛濺活動

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    Fabric.with(this, new Crashlytics(), new CrashlyticsNdk()); 
} 
相關問題