我正在尝试打开现有的pdf文件,然后在Android应用程序中向pdf文档添加另一个页面.在添加的页面上,我需要添加一些文本和图像.
我想试试PDFBox.由于许可条款/价格,iTextPDF等其他解决方案不适合我们公司.
我有一个带有主代码库的库项目,还有引用库项目的full和lite项目.
我从http://pdfbox.apache.org/download.html下载了jar 并将其复制到库项目lib文件夹中,并将pdfbox-app-1.6.0.jar文件添加到java构建路径库中.
我能够成功导入图书馆,import org.apache.pdfbox.pdmodel.PDDocument;并编译所有项目.但是,当我运行该应用程序时,它崩溃PDDocument document = new PDDocument();并出现以下错误.
E/AndroidRuntime(24451):java.lang.NoClassDefFoundError:org.apache.pdfbox.pdmodel.PDDocument
我在某处看到PDFBox版本1.5以后不适用于Android,所以我尝试下载pdfbox-app-1.4.0.jar文件,但遇到了同样的问题.我还在我的完整和精简版项目中将库添加到构建路径中,但是我得到了相同的错误或者eclipse因内存不足错误而崩溃.
谁能告诉我我做错了什么?我下载了错误的文件吗?我是否正确导入了它?
谢谢,
我正在使用DialogFragment.当用户与Gmail平板电脑应用程序中的屏幕下的示例图片中的编辑文本进行交互时,我希望正面和负面按钮保持在键盘上方.


在我的尝试不起作用,这是我的Dialog Fragments onCreateDialog方法
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater factory = LayoutInflater.from(getActivity());
final View textEntryView = factory.inflate(R.layout.my_layout, null);
return new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.paypal))
.setView(textEntryView)
.setPositiveButton(R.string.dialog_ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}
)
.setNegativeButton(R.string.dialog_cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}
)
.create();
}
Run Code Online (Sandbox Code Playgroud)
这是R.layout.my_layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">
<ImageView android:id="@+id/paypal_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dip"
android:layout_marginBottom="15dip"
/>
<EditText
android:id="@+id/edit_paypal_email"
style="@style/GeneralEditText"
android:hint="@string/contact_info_text_email"
android:inputType="textEmailAddress" …Run Code Online (Sandbox Code Playgroud) 我扩展了DialogFragment并从Fragment调用它(使用支持库,例如android.support.v4.app.Fragment)
Fragment实现包含doPositiveClick()方法的以下接口.
public interface CustomFieldsFragmentAlertDialog {
public abstract void doPositiveClick();
}
Run Code Online (Sandbox Code Playgroud)
为了显示对话框,我打电话给:
CustomFieldsDialogFragment dialog = CustomFieldsDialogFragment.newInstance();
dialog.show(getFragmentManager(), "fragmentDialog");
Run Code Online (Sandbox Code Playgroud)
这是我的DialogFragment类
public static class CustomFieldsDialogFragment extends DialogFragment{
public static CustomFieldsDialogFragment newInstance() {
CustomFieldsDialogFragment frag = new CustomFieldsDialogFragment();
return frag;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Title");
builder.setPositiveButton(posButtonText, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((CustomFieldsFragmentAlertDialog)getTargetFragment()).doPositiveClick();
}
});
}
return builder.create();
}
}
Run Code Online (Sandbox Code Playgroud)
尝试执行该行时,应用程序崩溃并出现空指针异常((CustomFieldsFragmentAlertDialog)getTargetFragment()).doPositiveClick();
10-05 13:45:23.550:E/AndroidRuntime(29228):java.lang.NullPointerException 10-05 13:45:23.550:E/AndroidRuntime(29228):at com.company.app.CustomFieldsFragment $ CustomFieldsDialogFragment $ …
我已经混淆了Lite和一个完整的项目,它们都引用了一个库项目。在运行时,我收到“ NoSuchMethodException myMethod”错误
根据http://proguard.sourceforge.net/index.html#/manual/troubleshooting.html,我必须在proguard.cfg中添加以下内容
-keep class mypackage.MyClass { void myMethod(); }
Run Code Online (Sandbox Code Playgroud)
我的方法返回一个String并接受3个String参数,因此我在proguard.cfg中添加了以下内容
-keep public class com.mycompany.appName.MyClass {
String myMethod(String, String, String);
}
Run Code Online (Sandbox Code Playgroud)
但是我仍然遇到同样的错误。
假设我正在构建精简版com.mycompany.appName.lite,我假设我不必在添加到proguard.cfg的行中更改软件包名称,因为它是一个引用的库。
有什么我想念的吗?谢谢。
我需要为android实现屏幕截图测试。
我已按照https://facebook.github.io/screenshot-tests-for-android/#gradle-setup上的步骤进行操作,并在我的 gradle 文件中包含以下内容
buildscript {
// ...
dependencies {
// ...
classpath 'com.facebook.testing.screenshot:plugin:0.9.0'
}
}
apply plugin: 'com.facebook.testing.screenshot'
Run Code Online (Sandbox Code Playgroud)
但是,我收到一个错误
评估根项目“app-android”时出现问题。未能应用插件 [id 'com.facebook.testing.screenshot'] 找不到名称为“androidTestImplementation”的配置。
我的 build.gradle 中有以下内容
androidTestImplementation 'androidx.test:core:1.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.multidex:multidex-instrumentation:2.0.0'
Run Code Online (Sandbox Code Playgroud)
我找不到任何证据表明我需要其他任何东西。
我也在https://github.com/facebook/screenshot-tests-for-android 上看到
你需要 python-2.7 才能让 gradle 插件工作,我们还建议安装 python-pillow 库,它是记录和验证屏幕截图所需的。
我已经安装了它并看到我有 2.7.16 版我还安装了枕头作为推荐(v6.0.0)
我正在使用PropertyValuesHolder为我的Android应用程序中的某些视图设置动画.动画在我的设备上正常运行,直到我做了一个没有任何动画的版本构建.(我认为问题与模糊处理有关,因为属性名称被称为字符串名称,例如"Panel1W")
没有异常抛出.只是没有动画.我在http://proguard.sourceforge.net/index.html#manual/troubleshooting.html 上找到的最接近的东西是NoSuchMethodException,我们需要在proguard.cfg中使用-keep命令.我在proguard.cfg中尝试了以下内容但没有成功
-keep public class com.mycompany.myapp.HomeActivity { java.lang.Integer getPanel1W(); }
-keep public class com.mycompany.myapp.HomeActivity { void setPanel1W(java.lang.Integer); }
-keep public class com.mycompany.myapp.HomeActivity { java.lang.Integer getPanel2W(); }
-keep public class com.mycompany.myapp.HomeActivity { void setPanel2W(java.lang.Integer); }
-keep public class com.mycompany.myapp.HomeActivity { java.lang.Integer getPanel3W(); }
-keep public class com.mycompany.myapp.HomeActivity { void setPanel3W(java.lang.Integer); }
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?这是下面的代码.谢谢.
PropertyValuesHolder[] arrayOfPropertyValuesHolder = new PropertyValuesHolder[3];
arrayOfPropertyValuesHolder[0] = PropertyValuesHolder.ofInt("Panel1W", mPanel1.getWidth(), 0);
arrayOfPropertyValuesHolder[1] = PropertyValuesHolder.ofInt("Panel2W", 360, 1280);
arrayOfPropertyValuesHolder[2] = PropertyValuesHolder.ofInt("Panel3W", 0, (int)(screenWidth * 0.65));
ObjectAnimator localObjectAnimator = ObjectAnimator.ofPropertyValuesHolder(this,
arrayOfPropertyValuesHolder).setDuration(time); …Run Code Online (Sandbox Code Playgroud)