Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLuke Kim
482 PointsHow 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
56,414 PointsYou'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.
Luke Kim
482 PointsCan u give me an example?
Luke Kim
482 PointsI still get the same error even when I change the name to something like,"com.overmind.FunFacts"
Seth Kroger
56,414 PointsWhat'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
482 Pointsit says that i need to change the package name because "com.example" is restricted
Seth Kroger
56,414 PointsSeth Kroger
56,414 PointsIf 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
482 PointsLuke Kim
482 PointsI 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'
}
allprojects { repositories { jcenter() } }
task clean(type: Delete) { delete rootProject.buildDir }
Seth Kroger
56,414 PointsSeth Kroger
56,414 Pointsshould be