gpt4 book ai didi

java - 合并 list 失败

转载 作者:行者123 更新时间:2023-12-02 04:43:03 26 4
gpt4 key购买 nike

an activity cannot be launched and the application is getting crashed

i tried to add some dependencies but it is failing to merge the manifest

   package com.example.penaliz;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseArray;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.google.android.gms.vision.CameraSource;
import com.google.android.gms.vision.Detector;
import com.google.android.gms.vision.text.TextBlock;
import com.google.android.gms.vision.text.TextRecognizer;

import java.io.IOException;


public class camActivity extends AppCompatActivity {

SurfaceView cameraView;

String s1;
TextView textView;
CameraSource cameraSource;
final int RequestCameraPermissionID = 1001;

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case RequestCameraPermissionID: {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
return;
}
try {
cameraSource.start(cameraView.getHolder());
} catch (IOException e) {
e.printStackTrace();
}

}
}
break;
}
}

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

cameraView = (SurfaceView) findViewById(R.id.surface_view);
textView = (TextView) findViewById(R.id.text_view);

TextRecognizer textRecognizer = new TextRecognizer.Builder(getApplicationContext()).build();
if (!textRecognizer.isOperational()) {
Log.w("MainActivity", "Detector dependencies are not yet available");
} else {

cameraSource = new CameraSource.Builder(getApplicationContext(), textRecognizer)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1280, 1024)
.setRequestedFps(2.0f)
.setAutoFocusEnabled(true)
.build();
cameraView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {

try {
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {

ActivityCompat.requestPermissions(camActivity.this,
new String[]{Manifest.permission.CAMERA},
RequestCameraPermissionID);
return;
}
cameraSource.start(cameraView.getHolder());
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {

}

@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
cameraSource.stop();
}
});

textRecognizer.setProcessor(new Detector.Processor<TextBlock>() {
@Override
public void release() {

}

@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {

final SparseArray<TextBlock> items = detections.getDetectedItems();
if(items.size() != 0)
{
textView.post(new Runnable() {
@Override
public void run() {
StringBuilder stringBuilder = new StringBuilder();
for(int i =0;i<items.size();++i)
{
TextBlock item = items.valueAt(i);
stringBuilder.append(item.getValue());
stringBuilder.append("\n");
}
textView.setText(stringBuilder.toString());

}
});

Button btn = (Button) findViewById(R.id.btn1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
s1=textView.getText().toString();

Intent i = new Intent(camActivity.this,Affance.class);
i.putExtra("message",s1);
startActivity(i);
}
});

}
}
});
}


}
}

it is showing the below log i cant understand it do i have to add some dependencies to make this work, i can run the app on android device, but when i try to launch the activityit is getting crashed

   '''`E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.penaliz, PID: 31333
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zztl;
at com.google.android.gms.vision.internal.client.zza.zzcls(Unknown Source:13)
at com.google.android.gms.vision.text.internal.client.zzg.<init>(Unknown Source:7)
at com.google.android.gms.vision.text.TextRecognizer$Builder.build(Unknown Source:6)
at com.example.penaliz.camActivity.onCreate(camActivity.java:63)
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:2926)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
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:1838)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6715)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zztl" on path: DexPathList[[zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/base.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_resources_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.android.gms.vision.internal.client.zza.zzcls(Unknown Source:13) 
at com.google.android.gms.vision.text.internal.client.zzg.<init>(Unknown Source:7) 
at com.google.android.gms.vision.text.TextRecognizer$Builder.build(Unknown Source:6) 
at com.example.penaliz.camActivity.onCreate(camActivity.java:63) 
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:2926) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081) 
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:1838) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6715) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911) 
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.penaliz-Y6sjCxlQmwAdFU1Jik2q8A==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
E/AndroidRuntime: at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2346)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5789)
at android.app.ActivityThread.access$1200(ActivityThread.java:208)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1680)
... 6 more`

what could i correct to make that activity too work this is the dependencies file

    apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.penaliz"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true;
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-vision:9.8.0'





}
apply plugin: 'com.google.gms.google-services'

and this is the manifest

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

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/sc"
android:label="@string/app_name"
android:roundIcon="@mipmap/roundlogo"
android:supportsRtl="true"
android:theme="@style/AppTheme"
>

<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ResetPassword" />
<activity android:name=".camActivity">



</activity>
<activity android:name=".FineList" />
<activity android:name=".Email_Send" />
<activity android:name=".Affance" />
<activity android:name=".MainActivity" />
</application>

</manifest>

最佳答案

该错误可能是因为这些依赖项具有不同的版本号:

implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'

所以尝试将它们更改为如下所示:

implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-core:16.1.0'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.google.firebase:firebase-storage:16.1.0'

还在您的依赖项中添加实现“com.android.support:multidex:1.0.3”

关于java - 合并 list 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56505694/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com