View Single Post
Old 07-23-2014, 03:28 PM   #1
Ricky23289
Nameless Being
 
Post Kindle Kindlet Jailbreak (KKJB) - Template project and HOWTO

Hi there,

first of all: I'd like to call it KKJB as "Kindle Jailbreak" and "Kindlet jailbreak" looks too much the same.

This project is based on the source code of KUAL and ixtab's KKJB.

If you simply use the template, read the following
Spoiler:

Todos for using the Project:
- Copy the folder AllPermissionKindletTemplate to your Workspace
- Rename to whatever the name of your new project should be
- import your kindle libraries to the project
- edit the entries in build.properties
-> at least: set the "product.mainclass"-value to a valid one that points to your class
-> decide which signing method you want to use
- extend your main class from com.mobileread.KKJBConnector.KKJBConnector


The things I've struggled with most:(don't get the same problems)
Spoiler:

- the KKJB jar (jailbreak.jar) must be in your project and included in your libraries list
- the three java files (kindletJailbreakAlternative, LauncherKindletJailbreak,OutputObject) must be in your project and referrable from other source files
- All the class-files, that are contained in the KKJB jar must be in your final azw2 file with the structure com/mobileread/ixtab/*.class otherwise you will get a "no main class found"-error


Complete walk-through for binding the KKJB in your Project. Just take the pieces out, that you need
Spoiler:

- create a new project
- (add the kindle-jars to the project)
- create a "libs" folder in your project
- Add the KKJB-jar to the "libs" folder (simply drag&drop it into the project)
- now you can go to project properties -> build path -> libraries -> add jar
and add the KKJB jar
- create a new file "build.xml" in your project (we're going to build our file using ant)
the file should have a content like this (edit the file with your data)
Spoiler:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="xxPROJECTNAMExx.makejar" default="makejar" basedir=".">	
  <property file="build.properties"/>

		<target name ="makejar" description="xxDESCRIPTIONxx">			
			<jar jarfile="xxOUTPUTNAMExx.azw2" includes="*.class" basedir="bin">
			    <manifest>
			    	<attribute name="Implementation-Vendor" value="${sign.aliases}"/>
			    	<attribute name="Extension-List" value="SDK"/>
			    	
			      <attribute name="Implementation-Title" value="${product.filename}"/>
			      <attribute name="SDK-Specification-Version" value="${product.kdk-version}"/>
			      <attribute name="Implementation-Version" value="${product.version}"/>
			      <attribute name="Toolbar-Mode" value="persistent"/>
			      <attribute name="SDK-Extension-Name" value="com.amazon.kindle.kindlet"/>
			      <attribute name="Main-Class" value="${product.mainclass}"/>
			    </manifest>  	
				
				<!-- this includes the KKJB jailbreak (NECESSARY!)-->
				<zipfileset src="libs/jailbreak.jar">
					<include name="**/*.class"/>
				</zipfileset>
				
				<!-- actual program files -->
				<fileset dir="${build.dir}">
					<include name="**/*.class"/>
				</fileset>
			</jar>	
			
			<!--
			 *********************************
			 **** signing the output file ****
			 *********************************
			-->
			 
			<!-- !!!! Use these commands instead, if it works for you !!! -->
			<!--
			<signjar jar="${file}" keystore="${sign.keystore.file}" storepass="${sign.keystore.password}" alias="dk${sign.aliases}"/>
			<signjar jar="${file}" keystore="${sign.keystore.file}" storepass="${sign.keystore.password}" alias="di${sign.aliases}"/>
			<signjar jar="${file}" keystore="${sign.keystore.file}" storepass="${sign.keystore.password}" alias="dn${sign.aliases}"/>
			-->
			<!-- signing jars the exec way, as ant is fucking to stupid to accept my classpath -.-"""" --> 
			
			<exec executable="${sign.jarsigner.path}">
				<arg value="-keystore"/>
				<arg value="${sign.keystore.path}/${sign.keystore.file}"/>
				<arg value="-storepass"/>
				<arg value="${sign.keystore.password}"/>
				<arg value="${file}"/>
				<arg value="dk${sign.aliases}"/>
			</exec>
			<exec executable="${sign.jarsigner.path}">
				<arg value="-keystore"/>
				<arg value="${sign.keystore.path}/${sign.keystore.file}"/>
				<arg value="-storepass"/>
				<arg value="${sign.keystore.password}"/>
				<arg value="${file}"/>
				<arg value="di${sign.aliases}"/>
			</exec>
			<exec executable="${sign.jarsigner.path}">
				<arg value="-keystore"/>
				<arg value="${sign.keystore.path}/${sign.keystore.file}"/>
				<arg value="-storepass"/>
				<arg value="${sign.keystore.password}"/>
				<arg value="${file}"/>
				<arg value="dn${sign.aliases}"/>
			</exec>
			
			
	</target>
</project>

! Make sure that the KKJB-jar is located in the "libs" folder. If not, change the location of the KKJB or edit the entry in the build.xml (at the position "this includes the KKJB jailbreak")
! the build.xml file will also sign the output for you, if you provide a proper path (see next point)

- create a "file build.properties" in your project
- the file should have a structure as follows (edit the content with your data)
Spoiler:

Code:
# do not change these values for compatibility among kindlets
sign.keystore.file=developer.keystore  
sign.keystore.password=password
sign.aliases=test

# the following two are only for using the command-line way to sign your files
sign.jarsigner.path=PATH_TO_JARSIGNER/jarsigner.exe
sign.keystore.path=PATH_TO_DEVELOPER.KEYSTORE

# this Version should point to the Version you're using
product.kdk-version=2.1
product.filename=xxNAME_OF_THE_OUTPUT_FILExx
product.extension=azw2
product.name=xxNAME_THAT_WILL_BE_DISPLAYED_ON_KINDLExx
product.version=1.0


product.vendor=xxPROBABLY_YOUR_NAMExx 
# change the following to match your class
product.mainclass=com.mobileread.KKJBTemplate
#product.image=KindleLauncher.jpg
build.dir=bin
#build.classpath.jdk14=/opt/j2sdk1.4.2_19/jre/lib


- create a new package com.mobileread.ixtab
- copy the following files in there:
Spoiler:

- kindletJailbreakAlternative.java
- LauncherKindlet.Jailbreak.java
- OutputObject.java


at least from here, you should look into the files included in this post. If you mostly know what to do, you can follow the steps on here
- create a new class, that extends SuicidalKindlet in the package com.mobileread.KKJBConnector
- you also need to import the KKJB classes with
Spoiler:

import ixtab.jailbreak.Jailbreak;
import ixtab.jailbreak.SuicidalKindlet;
import com.mobileread.ixtab.LauncherKindletJailbreak;

- create the following method (this is important!):
Spoiler:

Code:
protected Jailbreak instantiateJailbreak() {
		return new LauncherKindletJailbreak();
	}
- if LauncherKindletJailbreak could not be found:
it's declared in "LauncherKindletJailbreak.java". Make sure it is included in your project and imported in the file

- create a method "onstart" that looks at least like this
Spoiler:

Add a boolean variable to the class called "started" (initial value = false)
Code:
public void onStart() 
	{
		// apparently this method gets called various times
		if (started) {
			return;
		}
		super.onStart();
		started = true;
		
		/*** 
			your Code might come here
		***/

	}


- create an onCreateMethod:
Spoiler:

Code:
private KindletContext context;
public void onCreate(KindletContext context)
	{
		super.onCreate(context);		
		this.context = context;		
	}



Where do I find the KKJB?
Spoiler:

ixtab provided a home for it:
https://bitbucket.org/ixtab/kindletjailbreak


Please let me know, if there a any issues with the project. I hope I've removed all the my-computer-specific-stuff.
And it would be nice, if this is helpful for anybody
Attached Files
File Type: zip AllPermissionKindletTemplate.zip (23.7 KB, 165 views)

Last edited by Ricky23289; 08-12-2014 at 04:33 AM. Reason: Forgot to add the project
  Reply With Quote