2017-04-16 66 views
0

我尝试使用Stetho时遇到问题,我尝试搜索并按照其他人提供的步骤操作,但似乎没有人强调我的问题。以下是我需要的Stetho使用文件。Stetho - Android Studio初始化

我的问题是它不能识别方法“初始化”我试图通过执行其他用户的建议方法的其他方式,但我仍然满足同样的错误

的build.gradle(模块:应用)

dependencies { 

compile 'com.facebook.stetho:stetho:1.5.0' 
compile 'com.facebook.stetho:stetho-okhttp3:1.5.0' 

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' 
compile 'com.android.support:support-v4:24.2.1' 
testCompile 'junit:junit:4.12' 
} 
我Stetho应用类

import android.app.Application; 

public class Stetho extends Application { 

@Override 
public void onCreate() { 
    super.onCreate(); 

    Stetho.initializeWithDefaults(this); 


    } 
} 

在我的清单

012宣布
<application 
    android:name=".Stetho" 
     android:allowBackup="true" 

我认为问题是,我实际上没有正确实施库,但我不确定。

+0

命名confict。为你的班级选择一个不同的名字。 – SAM

回答

2

您可能会因为您的应用程序类别被命名为Stetho而发生名称冲突。在.java和.manifest文件中重命名您的App类。将Stetho包导入您的应用类。

您的应用程序类应该是这个样子:

import android.app.Application; 
import com.facebook.stetho.Stetho; 

public class MyApp extends Application { 

    @Override 
    public void onCreate() { 
     super.onCreate(); 

     Stetho.initializeWithDefaults(this); 

    } 
} 

而且你的表现是这样的:

<application 
    android:name=".MyApp" 
    android:allowBackup="true" /> 
+0

啊是的,我有一个名称冲突,非常感谢你!它现在按预期工作。 –