简体   繁体   English

Android Studio:向现有包添加新的java文件-“未解析的引用”

[英]Android Studio : Adding a new java file to an existing package - "Unresolved Reference"

I was looking the HTML to PDF Conversion in android app在 android 应用程序中寻找HTML 到 PDF 的转换

I have a problem to do the "it must be in package ".../java/android/print/" from solution number 1. How can I add the PdfConverter.java in android.print packages and the android studio recognise it ?我有一个问题要从解决方案 1 中执行“它必须在包“.../java/android/print/”中。如何在 android.print 包中添加 PdfConverter.java 并且 android studio 识别它?

When I add it manually, fixing an PdfConverter.java and add it to the directory, the android studio do not recognise it and i got "Unresolved Reference : PdfConverter".当我手动添加它,修复 PdfConverter.java 并将其添加到目录时,android studio 无法识别它,我得到了“未解析的参考:PdfConverter”。

Is there another way, appropriate, to add the PdfConverter.java in the android.print package without getting the above error ?是否有另一种适当的方法在 android.print 包中添加 PdfConverter.java 而不会出现上述错误?

Thank you in advance.先感谢您。

Add the java class in such own-made package tree (right-click on java directory -> New -> Package -> name it "android", then do the same with "print", then add to this package the PdfConverter):在这样自己制作的包树中添加java类(右键单击java目录->新建->包->将其命名为“android”,然后用“print”做同样的事情,然后将PdfConverter添加到这个包中):

在此处输入图片说明

PdfConverter class is accessing PrintDocumentAdapter, from Android SDK's android.print package. PdfConverter 类正在从 Android SDK 的 android.print 包访问 PrintDocumentAdapter。 You should made a package in project named android.print and I put PdfConverter class there and there would be no errors from lint in IDE.你应该在名为 android.print 的项目中创建一个包,我把 PdfConverter 类放在那里,IDE 中的 lint 不会有错误。

Structure should be same as on this github repo https://github.com/blink22/react-native-html-to-pdf/tree/master/android结构应与此 github 存储库相同https://github.com/blink22/react-native-html-to-pdf/tree/master/android

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

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