Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Publish an Android App Publishing on Google Play Uploading an APK

Luke Kim
Luke Kim
482 Points

How do I fix the com.example problem?

It says that it wont allow my apk because it has to do something with "com.example" being restricted. Can someone help me out please?

4 Answers

Seth Kroger
Seth Kroger
56,405 Points

You'll need to rename your package as something else. You can do that easily enough by using Refactor -> Rename on the package folder in the project pane. The app name can stay the same but the domain name needs to change to something more personalized.

Seth Kroger
Seth Kroger
56,405 Points

If you have your own internet domain you can use that, reversed of course. That's the long established standard specified in Java by Sun/Oracle: https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html It would look like

package com.sethkroger.funfacts;

Without owning a domain you can make up a package name prefix. I recommend that instead of using a domain you don't own. For instance I could start with sethk.apps for apps by me. Then the package would be:

package sethk.apps.funfacts;

also see for other perspectives:

http://stackoverflow.com/questions/12535798/whats-the-convention-for-java-package-names-without-a-domain-association

http://stackoverflow.com/questions/292169/what-package-naming-convention-do-you-use-for-personal-hobby-projects-in-java?rq=1

Luke Kim
Luke Kim
482 Points

I found out that I also messed up the gradle on the class path. How do I name it correctly again? Also I renamed the Apk "Overmind121-release" still no luck.

Code:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript { repositories { jcenter() } dependencies { classpath 'com.Overmind121'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects { repositories { jcenter() } }

task clean(type: Delete) { delete rootProject.buildDir }

Seth Kroger
Seth Kroger
56,405 Points

should be

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
Luke Kim
Luke Kim
482 Points

Can u give me an example?

Luke Kim
Luke Kim
482 Points

I still get the same error even when I change the name to something like,"com.overmind.FunFacts"

Seth Kroger
Seth Kroger
56,405 Points

What's the exact error message? are you unable to compile the apk or is the apk being rejected? Does the app name in build.gradle and the manifest match the new package?

There are two issues I can think of: 1) package names are supposed to be all lowercase (see the Oracle doc I linked to above) 2) Chrome throws a hard "Deceptive Site" warning if you try to go the the domain, one of many reasons for my advice to never use a domain you don't own.

Luke Kim
Luke Kim
482 Points

it says that i need to change the package name because "com.example" is restricted