【发布时间】:2016-05-24 17:03:45
【问题描述】:
我试图在我的片段视图膨胀时显示小吃栏。 我已经在 onViewCreated 中编写了小吃店代码,它可以工作并向我展示小吃店。但是当我尝试 setAction 并设置 onClickListener 时,Build gradle 失败。我附上代码 sn-p 和错误日志。
FragmentContact.java
public void onViewCreated(View v, Bundle savedInstanceState) {
Snackbar.make(getActivity().findViewById(android.R.id.content), "Doubt?", Snackbar.LENGTH_LONG)
.setAction("Call",new View.OnClickListener(){
@Override
public void onClick(View v) {
}
})
.show();
错误日志
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0\bin\java.exe'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 44.306 secs
gradle中的依赖
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.android.support:support-v4:23.1.0'
compile "com.android.support:support-v4:+"
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
}
【问题讨论】:
-
你能用 gradle 文件中的代码编辑问题吗?
-
运行 gradlew assemble --info 并发布详细信息
标签: android android-fragments android-snackbar