keystore and Netbeans

  4 posts   Feedicon  
Replies: 3 - Last Post: August 18, 2010 14:51
by: max246
showing 1 - 4 of 4
 
Posted: January 08, 2010 17:39 by incal
Hi,
I'm an Italian developer, I wrote an application for Android with Netbeans, because I prefer it to Eclipse.
I'd like to certify the file . apk with a my keystore directly from Netbeans so that the emulator run my application signed with a valid key, it's possible?

Thank's in advance, regards
Maurizio
 
Posted: January 09, 2010 11:11 by incal
Hi,
I have try this solution:
I left out the default signature of the file .apk entering argument
<arg value="-u"/>
in the target
-sign
in my project build-inpl.xml.
After I have added a new target

<target depends="init,-package-res-and-assets,-package-res-no-assets,-package-dex,-sign" name="-mysign">
        <signjar alias="my_alias" jar="${basedir}/${dist.apk}" keypass="mypass" keystore="pathkeystore\my.keystore" signedjar="${basedir}/${dist.apk}" storepass="mypass"/>
    </target> 


now when I build the project is marked with my dedicated key and the procedure seems to work but I still have to perform more extensive tests.
I think it would be interesting to integrate the functionality into plugins

Any suggestions ?, regards,
Maurizio
 
Posted: January 23, 2010 09:00 by stantemo
Hi!

I had the same problem but found a rather interesting solution.

My specs. are:
OS X 10.5.8
Netbeans 5.7.1
nbandroid 0.10

This is what I did.
1. I opened "build-impl.xml" in Netbeans and scrolled down to the "-sign"-taget.
2. I added <arg value="-u"/> to the args-list making the target look like this.

<target depends="init,-package-res-and-assets,-package-res-no-assets,-package-dex" name="-sign">
        <exec executable="${apkbuilder}" failonerror="true">
            <arg value="${basedir}/${dist.apk}"/>
            <arg value="-u"/>
            <arg value="-z"/>
            <arg value="${basedir}/${dist.apk}_"/>
        </exec>
        <delete file="${dist.apk}_"/>
</target>


3. I made a clean build.
4. Signed the .apk from commandline using this command.
jarsigner -verbose -keystore ~/mykey.keystore -signedjar ~/myapp_signed.apk ~/NetBeansProjects/myapp/dist/myapp.apk mykey.keystore


5. Uploaded it to Google which accepted the .apk.

Nothing wierd so far. As expected when i try to run my application in the emulator it says it is not signed and will not run. Fair enough, lets comment that change I made in build-impl.xml making it look like this.

<target depends="init,-package-res-and-assets,-package-res-no-assets,-package-dex" name="-sign">
        <exec executable="${apkbuilder}" failonerror="true">
            <arg value="${basedir}/${dist.apk}"/>
            <!-- <arg value="-u"/> -->
            <arg value="-z"/>
            <arg value="${basedir}/${dist.apk}_"/>
        </exec>
        <delete file="${dist.apk}_"/>
</target>


Running again and everything wolks like a charm.
Now for the weird part.
If I cleand build the project, run my sign command-line it will do so without a hassle. I even tried to upload it to Google and no errors.


Hops this could be useful for someone.
 
Posted: August 18, 2010 14:51 by max246
I have insert this on my project.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.android.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/android-project/1">
<name>CercaTarga</name>
<minimum-ant-version>1.7.0</minimum-ant-version>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
<target depends="init,-package-res-and-assets,-package-res-no-assets,-package-dex" name="-sign">
<exec executable="${apkbuilder}" failonerror="true">
<arg value="${basedir}/${dist.apk}"/>
<arg value="-u"/>
<arg value="-z"/>
<arg value="${basedir}/${dist.apk}_"/>
</exec>
<delete file="${dist.apk}_"/>
</target>
</project>



But when restart the netbeans don't see the project.
When try to open my project told me this error : Error in project.xml: Invalid content was found starting with element 'target'. No child element is expected at this point.

Why?

Netbenas 6.8
Windows xp
Replies: 3 - Last Post: August 18, 2010 14:51
by: max246
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close