简体   繁体   English

当我在应用程序中实现 barteksc 时,我的应用程序崩溃了

[英]when i implement barteksc in app my app just crash

when i try to implement当我尝试实施

 implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

in my android application my app just crash, it start and show the dialogue of close app, i cant find out what and where the issue is在我的 android 应用程序中,我的应用程序刚刚崩溃,它启动并显示关闭应用程序的对话,我无法找出问题所在

this is my gradle file这是我的 gradle 文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "30.0.1"
defaultConfig {
//    -keep class com.shockwave.**

    applicationId "com.example.quran"
    minSdkVersion 16
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

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

 dependencies {
  implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'


}

this is my xml file这是我的 xml 文件

    <com.github.barteksc.pdfviewer.PDFView
      android:layout_width="match_parent"
       android:layout_height="match_parent"
      android:id="@+id/quran"
      />

this is my java file这是我的 java 文件

PDFView pdfView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_whole_quran);

    pdfView=findViewById(R.id.quran);
    pdfView.fromAsset("complete_quran")
            .defaultPage(0)

            .enableAnnotationRendering(true)
            .scrollHandle(new DefaultScrollHandle(this))
            .spacing(2)
            .load();
}

this is the logcat这是日志猫

E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.quran, PID: 13976
  java.lang.RuntimeException: Unable to start activity 
  ComponentInfo{com.example.quran/com.example.quran.MainActivity}: java.lang.IllegalStateException: 
   You need to use a Theme.AppCompat theme (or descendant) with this activity.
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2956)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3091)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at 
      
    android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1843)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6758)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912)
     Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or 
      descendant) with this activity.
      at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:843)
      at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806)
      at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:693)
      at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
      at com.example.quran.MainActivity.onCreate(MainActivity.java:20)
      at android.app.Activity.performCreate(Activity.java:7136)
      at android.app.Activity.performCreate(Activity.java:7127)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2933)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3091) 
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
      at 
    android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1843) 
       at android.os.Handler.dispatchMessage(Handler.java:106) 
       at android.os.Looper.loop(Looper.java:193) 
       at android.app.ActivityThread.main(ActivityThread.java:6758) 
       at java.lang.reflect.Method.invoke(Native Method) 
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497) 
             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912) 

its manifest is given here.. kindly check if there needed any kind of permission...它的清单在这里给出……请检查是否需要任何许可……

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.quran"> 

   <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=".wholeQuran"></activity>
      <activity android:name=".surah_shown" />
      <activity android:name=".surahActivity" />
      <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>

Try changing android:theme="@style/AppTheme" to android:theme="@style/Theme.AppCompat.Light" in your manifest.尝试在android:theme="@style/AppTheme"更改为android:theme="@style/Theme.AppCompat.Light"

try to add classpath 'com.github.barteksc:pdfium-android:1.9.0' in gradle project尝试在gradle project中添加classpath 'com.github.barteksc:pdfium-android:1.9.0'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM