So, as we discovered in my post last night, renaming the package of an application is far from being a trivial process. Somehow or other, the whole R file thing manages to jam up the works. It doesn't seem to find it under the new package name.
One possible approach is to pull it out of svn to another project, as kind of sandbox, and then rename, then delete the android project and import it from existing code into Eclipse.
Actually, I need to restore some code I lost when I reverted. This even an improvement to get the database name:
databasePath = "/data/." + context.getPackageName() + "/";
Hmm...it seems to be loading to a different path than I expected. Let's see if we can find it in adb shell.
No, that's right - I had previously been making the data directory a different one from the app. So, now it's the same.
Ok, so that problem is solved. Let's commit and start our experiment.
Actually, I'll just copy the project in Eclipse. For the heck of it, I'm going to try the rename experiment again, just in case:
No, the same problem. Before I try the import, let's make sure that the package name in the manifest has to match...
Yes. Ok, let's google it.
There are some good answers on SO:
http://stackoverflow.com/questions/3697899/package-renaming-in-eclipse-android-project
I like this one:
"This is a bug in eclipse android tools http://code.google.com/p/android/issues/detail?id=2824
To Fix -> Right click on the project go to Android tools -> Rename application package..
And also check AndroidManifest.xml if it updated correctly, in my case it didn't, that should solve this problem"
Yes - it works like charm. Sweet.
Ok. So, let's make sure this works...
Ok, the licensing server isn't set up for this test yet. It's returning an error "Market Not Managed".
Uh-oh - it proceeded to download media anyway. Also, the title is the the same on both icons, some I have to change in the manifest under app name, I think.
It looks like it installed the media, despite the licence issue. I neet to fix that.
The problem is it's a callback. So, should I initiate the media download base on the callback? The validation is only called some of the time, and not on the free version. Maybe I should initiate the download from the questions activity? Or from the first time it tries to play media?
Well for now, if it's paid, I'll call it from the validation check, otherwise call it as it is now. Actually, the best thing to do would be to have something listen for a valid check, and kick off the download.
I should be able to work it through the mHandler. How does it work in this case?
Ok, how about this, when it is successful:
// will download only if audio data isn't already there
new DownloadAudioData().initiateDownload(ValidateLicense.this.mActivity);
And in the regular startActivity,
if (Utils.isFree(this)) {
// will download only if audio data isn't already there
new DownloadAudioData().initiateDownload(this);
}
There will have to be at least two versions, because for the free version, you can't include the validate code.
Ok, let's try this again.
I will have to change the string app name also.
So, there will be a few things:
Strings:
AppName
JLPT level
Nag Number
Code:
Comment out validation code
Delete validation jar from project
Manifest:
Package Name
Not trivial!
What about branching? Just a simple branch, and just keep merging in from the main trunk? I dunno. Sounds like a hassle. Let's google it.
Ok, the recommended solution seems to be to create a library project, per this post:
http://stackoverflow.com/questions/4165175/how-to-manage-multiple-editions-of-the-same-android-app
"Use an Android library project for the common code, with tiny projects for each specific flavor."
Well, let's see if this works, at least...
Ok, good. That killed it in its tracks. No media download.
I should probably go ahead and set up that common project. It will be worth it. I'll tackle it in an upcoming post.
No comments:
Post a Comment