简体   繁体   English

错误:包 R 不存在。 我必须添加这些包吗?

[英]error: package R does not exist. Do I have to add the packages?

I have added some java functions from Project A into Project B. Then, when I try to run Project B, I received the error.我已将项目 A 中的一些 java 函数添​​加到项目 B 中。然后,当我尝试运行项目 B 时,收到错误消息。 When I compare the xml file from both projects, they have different packages.当我比较两个项目的 xml 文件时,它们有不同的包。

So do I need to add the packages from Project A into Project B as well ?那么我是否需要将项目 A 中的包也添加到项目 B 中? If yes, how do I do that ?如果是,我该怎么做?

Please help, I am very new to this请帮忙,我对此很陌生

Code for Project B is as below项目B的代码如下

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.tensorflow.demo"
>

Code for Project A is as below项目A的代码如下

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gms.samples.vision.ocrreader"
android:installLocation="auto" >

These are the files that I added from Project A to Project B Files from Project A ,这些是我从项目 A 添加到项目 B文件从项目 A 的文件

Added into Project B添加到项目B

the new error新的错误

This is one of the most common errors you get when you copy-paste Java classes from one project to another.这是将 Java 类从一个项目复制粘贴到另一个项目时最常见的错误之一。

What you need to do is: You need to copy those three classes right?您需要做的是:您需要复制这三个类对吗? So, in Project B, make three new classes of the same name and each time copy paste the code of those three classes from Project A, just excluding the name of the package, which is in the first line of every class.因此,在项目 B 中,创建三个同名的新类,每次从项目 A 中复制粘贴这三个类的代码,只是不包括包的名称,它位于每个类的第一行。 Then compile the project B. Your errors should be resolved.然后编译项目B。你的错误应该得到解决。

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

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