开发者

Multiple Packages in an Android App

开发者 https://www.devze.com 2023-01-01 12:57 出处:网络
I am including a class in my app that anoth开发者_运维技巧er developer has made freely available. His class has a different package.

I am including a class in my app that anoth开发者_运维技巧er developer has made freely available. His class has a different package.

Will this cause any issues on Android, the market, etc? Does every single class in the app need to be my own package?


Despite this being a very old question, I'd like to clarify: Java-level "packages" (which the question is about) and Android .APK "packages" are two different beasts. Java-level "packages" are namespaces to organize classes within your app, whereas the Android "package" name provides a globally unique identifier for your entire app.

Usually at least part of the Java sources in a project is in a Java-level "package" (namespace) matching the Android package name of the app, but that is just for convenience and is not at all required. It is very common to have several Java packages within your app project. Adding to the project 3-rd party Java classes with different namespaces does not affect the name of the resulting Android package. The entire project must have a globally unique Android package name defined in the Manifest, which is later used to identify your app within Google Play.


You are allowed to use other packages, sources and libraries. Eclipse makes that all very easy to do in the properties page of the project.

The main issue is usually making sure you obey the licences and agreements of the code you are using. Make sure you understand the implications and include credit to the developers, as well as references to the agreements as they state. If you don't, it could cause problems down the line.


It doesn't have to by in Your own package. Also You can use external jars, or external eclipse projects or external source folders for easier project maintenance.

0

精彩评论

暂无评论...
验证码 换一张
取 消