简体   繁体   中英

Unable to fix package path error in Android Studio

在此处输入图片说明

As you can see in the screenshot above, all the imports of LipeRMI classes are in vain. What should be the right path statement to have them imported correctly? I face the same error in MainActivity for: import lipermi.handler.CallHandler; import lipermi.net.Client; import lipermi.handler.CallHandler; import lipermi.net.Client;

I know such questions regarding android studio have been asked many times but I just fail to understand how to fix this problem. FYI, I dragged the net.sf.lipermi folder into com.example.akash.chatapplication folder.

Thank you for your time. :)

EDIT - After following Tanis.7x's answer, this is the updated hierarchy as well as the MainActivity code- 在此处输入图片说明

您应该将src/main/com/example/akash/chatapplication/net移至src/main

By dragging the net.sf.lipermi folder into the com.example.akash.chatapplication folder, you have altered the package for those classes.

This won't compile, because the folder path needs to match these classes' package declaration. This this case, the package would have to be com.example.akash.chatapplication.net.sf.lipermi , which is clearly not what you want.

If you really need to copy these classes into your project, you should copy them into the src/main folder instead of into your application's package.

The best route is to include these files as a dependency in your build.gradle . However, not all libraries offer this option. If that library provides a JAR file, you should instead include that JAR in your project's libs folder. Including the raw source in your project should always be a last resort.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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