实际上我想在我的应用程序中添加Picasso或Glide库但是每当我使用它们的依赖关系时我都会收到错误(请查看下面的屏幕了解更多细节)我正在使用Android Studio 3.0.1我尝试了几乎所有解决方案,如即时运行未选中,脱机更新未选中,添加多索引更改SDK版本更高27.0.1请建议
glide库的错误是java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代)。
style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.neuralit.developer.myapplicationtest">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
尝试使用这个Gradle for Glide
compile 'com.github.bumptech.glide:glide:3.7.0'
保持compileSdkVersion
到26
有不同的问题:
#1您必须在同一个gradle文件中添加Glide和Picasso('app'文件夹中的文件)。删除app\src\androidTest\java
中的那个
编辑
#2 Glide 4不支持库26。
See Glide documentaiton for more info
编辑2
实际上,如果你真的想要,你仍然可以使用v26(参见上面的文档,但不推荐)。但无论如何你不应该使用测试版,因为26已经发布了一段时间。因此,如果你想保留26,你应该使用26.0.2,它有bug修复。 (implementation 'com.android.support:appcompat-v7:26.0.2'
)
#3根据您提供的最后一个屏幕截图,您可能还有另一个问题。但是如果问题仍然存在,请修复第一个并回到我们这里。
但是,由于Glide和Picasso应该做同样的事情,你为什么要同时使用它们呢?