gpt4 book ai didi

java - '源代码与字节码不匹配' Android Studio

转载 作者:行者123 更新时间:2023-12-04 23:01:56 24 4
gpt4 key购买 nike

我正在使用 Android Studio 4.01 版中的 FFmpeg 库开发一个 Android 视频编辑应用程序。当我尝试调试时,调试器会进入反编译器并在反编译代码的多个步骤中闪烁“源代码与字节码不匹配”。调试器似乎也在半随机地跳转反编译代码,例如:here ,其中 logSlowDispatch 为 false,但调试器无论如何都会进入 if 语句的内容而不检查并闪烁“源代码与字节码不匹配”。我查看了很多关于这个问题的帖子,并尝试了许多建议的解决方案,从无效缓存/重启到全新安装 Android Studio 无济于事。我读过冗余或过时的 gradle 依赖项可能与此有关,但删除其中一些依赖项并没有帮助:

apply plugin: 'com.android.application'

android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.capstoneapplication"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndkVersion "21.3.6528147"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support.constraint:constraint-layout:2.0.0'

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.writingminds:FFmpegAndroid:0.3.2'

implementation 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'

implementation 'com.intuit.sdp:sdp-android:1.0.6'
}
我的代码似乎运行正常,并在这些跳转到反编译器之间的所需视频上执行 ffmpeg 命令,但视频没有保存。以下是可能导致此问题的 java 类的一个 fragment :
    @Override
public boolean onOptionsItemSelected(MenuItem menuItem){
if(menuItem.getItemId()==R.id.trim){
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(com.example.capstoneapplication.VideoTrimmer.this);

LinearLayout linLay = new LinearLayout(com.example.capstoneapplication.VideoTrimmer.this);
linLay.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams layPar = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layPar.setMargins(50, 0, 50, 100 );
final EditText input = new EditText(com.example.capstoneapplication.VideoTrimmer.this);
input.setLayoutParams(layPar);
input.setGravity(Gravity.TOP|Gravity.START);
input.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
linLay.addView(input,layPar);

alertDialog.setMessage("Enter Video Name");
alertDialog.setTitle("Change Video Name");
alertDialog.setView(linLay);
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
fileName = input.getText().toString();

try {
snipVideo(videoDurBar.getAbsoluteMinValue().intValue(), videoDurBar.getSelectedMaxValue().intValue(), fileName);
} catch ( FFmpegNotSupportedException e) {
e.printStackTrace();
}


}
});
alertDialog.show();
}
return super.onOptionsItemSelected(menuItem);
}

private void snipVideo( int min, int max, String fileName) throws FFmpegNotSupportedException {

File destFolder = new File("storage/emulated/0" + "/EditingApeSnippedVideos");
if(!destFolder.exists()){
destFolder.mkdir();
}
String fileExtension = ".mp4";
destination = new File(destFolder, fileName + fileExtension);
inputVideoPath = getPathFromUri(getApplicationContext(),uri);


command = new String[]{"-ss", "" + min/1000 , "-y", "-i", inputVideoPath, "-t", ""+ (max-min)/1000 ,"-vcodec", "mpeg4", "-b:v","2097152","-b:a", "48000", "-ac","2","-ar","22050", destination.getAbsolutePath()};

//testing command
//command = new String []{"-y", "-i", inputVideoPath, "-ss", "00:00:02" , "-to", "00:00:03", "-c", "copy", destination.getAbsolutePath()};
final FFmpeg ff = FFmpeg.getInstance(this);
ff.loadBinary(new FFmpegLoadBinaryResponseHandler() {

@Override
public void onStart() {

Log.i("VideoTrimmer","onStart");
}

@Override
public void onFinish() {
Log.i("VideoTrimmer","onFinish");
}

@Override
public void onFailure() {
Log.i("VideoTrimmer","onFailure");
}

@Override
public void onSuccess() {
Log.i("VideoTrimmer","Success");
try {
ff.execute(command, new ExecuteBinaryResponseHandler());
} catch (FFmpegCommandAlreadyRunningException e) {
Log.i("VideoTrimmer","FFmpegAlreadyRunning Exception");

}
}
});
}
有没有人找到解决此调试器问题的方法?

最佳答案

我不熟悉 Android,但在 IntelliJ 中也可以看到这种行为。不知何故,调试器指向旧的编译文件而不是新的。
在 java 的情况下,您始终可以删除目标文件夹并重新构建。查看您是否在某处(目标文件夹)有任何类似的编译文件,您可以将其删除并再次构建。
完成后,单击 File -> Invalidate Caches/Restart

关于java - '源代码与字节码不匹配' Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63594888/

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