├── .gitignore ├── lib ├── dex2jar │ ├── dx.jar │ ├── dex-ir-1.12.jar │ ├── jasmin-p2.5.jar │ ├── asm-all-3.3.1.jar │ ├── dex-reader-1.15.jar │ ├── jar-rename-1.6.jar │ ├── commons-lite-1.15.jar │ ├── dex-tools-0.0.9.15.jar │ └── dex-translator-0.0.9.15.jar ├── apktool │ └── apktool.jar ├── commons-io-2.4.jar ├── commons-lang3-3.1.jar ├── dom4j-2.0.0-ALPHA-2.jar └── jd-core │ ├── win32 │ ├── x86 │ │ └── jd-intellij.dll │ └── x86_64 │ │ └── jd-intellij.dll │ ├── linux │ ├── x86 │ │ └── libjd-intellij.so │ └── x86_64 │ │ └── libjd-intellij.so │ └── macosx │ ├── x86 │ └── libjd-intellij.jnilib │ └── x86_64 │ └── libjd-intellij.jnilib ├── .project ├── .settings └── de.loskutov.anyedit.AnyEditTools.prefs ├── starting ├── setclasspath.bat ├── deapk.bat └── deapk.sh ├── src ├── jd │ └── ide │ │ └── intellij │ │ ├── config │ │ ├── JavaDecompilerConfigurationAccess.java │ │ └── JDPluginComponent.java │ │ ├── JavaDecompilerService.java │ │ ├── JavaDecompilerClassFileProcessor.java │ │ └── JavaDecompiler.java ├── i │ └── am │ │ └── jiongxuan │ │ └── deapk │ │ ├── ArchUtils.java │ │ ├── jd │ │ └── core │ │ │ ├── DecompilerException.java │ │ │ ├── DecomplieEntry.java │ │ │ ├── Decompiler.java │ │ │ └── DecomplieEnumeration.java │ │ ├── PercentWritter.java │ │ ├── MainApplication.java │ │ ├── GenerateProjectOperator.java │ │ └── Deapk.java └── com │ └── intellij │ └── openapi │ ├── fileTypes │ └── ContentBasedClassFileProcessor.java │ ├── application │ ├── ApplicationManager.java │ └── Application.java │ └── components │ └── ComponentManager.java ├── .classpath ├── NOTICE ├── README.md ├── CHANGELOG.txt └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | -------------------------------------------------------------------------------- /lib/dex2jar/dx.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/dx.jar -------------------------------------------------------------------------------- /lib/apktool/apktool.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/apktool/apktool.jar -------------------------------------------------------------------------------- /lib/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/commons-io-2.4.jar -------------------------------------------------------------------------------- /lib/commons-lang3-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/commons-lang3-3.1.jar -------------------------------------------------------------------------------- /lib/dex2jar/dex-ir-1.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/dex-ir-1.12.jar -------------------------------------------------------------------------------- /lib/dex2jar/jasmin-p2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/jasmin-p2.5.jar -------------------------------------------------------------------------------- /lib/dom4j-2.0.0-ALPHA-2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dom4j-2.0.0-ALPHA-2.jar -------------------------------------------------------------------------------- /lib/dex2jar/asm-all-3.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/asm-all-3.3.1.jar -------------------------------------------------------------------------------- /lib/dex2jar/dex-reader-1.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/dex-reader-1.15.jar -------------------------------------------------------------------------------- /lib/dex2jar/jar-rename-1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/jar-rename-1.6.jar -------------------------------------------------------------------------------- /lib/dex2jar/commons-lite-1.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/commons-lite-1.15.jar -------------------------------------------------------------------------------- /lib/dex2jar/dex-tools-0.0.9.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/dex-tools-0.0.9.15.jar -------------------------------------------------------------------------------- /lib/jd-core/win32/x86/jd-intellij.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/jd-core/win32/x86/jd-intellij.dll -------------------------------------------------------------------------------- /lib/dex2jar/dex-translator-0.0.9.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/dex2jar/dex-translator-0.0.9.15.jar -------------------------------------------------------------------------------- /lib/jd-core/linux/x86/libjd-intellij.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/jd-core/linux/x86/libjd-intellij.so -------------------------------------------------------------------------------- /lib/jd-core/win32/x86_64/jd-intellij.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/jd-core/win32/x86_64/jd-intellij.dll -------------------------------------------------------------------------------- /lib/jd-core/linux/x86_64/libjd-intellij.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/jd-core/linux/x86_64/libjd-intellij.so -------------------------------------------------------------------------------- /lib/jd-core/macosx/x86/libjd-intellij.jnilib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/jd-core/macosx/x86/libjd-intellij.jnilib -------------------------------------------------------------------------------- /lib/jd-core/macosx/x86_64/libjd-intellij.jnilib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiongxuan/deapk/HEAD/lib/jd-core/macosx/x86_64/libjd-intellij.jnilib -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Deapk 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.settings/de.loskutov.anyedit.AnyEditTools.prefs: -------------------------------------------------------------------------------- 1 | activeContentFilterList=*.makefile,makefile,*.Makefile,Makefile,Makefile.*,*.mk,MANIFEST.MF 2 | addNewLine=true 3 | convertActionOnSaave=AnyEdit.CnvrtTabToSpaces 4 | eclipse.preferences.version=1 5 | ignoreBlankLinesWhenTrimming=false 6 | inActiveContentFilterList= 7 | javaTabWidthForJava=true 8 | org.eclipse.jdt.ui.editor.tab.width=4 9 | projectPropsEnabled=false 10 | removeTrailingSpaces=true 11 | replaceAllSpaces=false 12 | replaceAllTabs=false 13 | saveAndAddLine=false 14 | saveAndConvert=true 15 | saveAndTrim=true 16 | useModulo4Tabs=false 17 | -------------------------------------------------------------------------------- /starting/setclasspath.bat: -------------------------------------------------------------------------------- 1 | REM 2 | REM Deapk - A tools for "APK -> Eclipse Project" 3 | REM Copyright (c) 2013-2014 Jiongxuan Zhang 4 | REM 5 | REM Licensed under the Apache License, Version 2.0 (the "License"); 6 | REM you may not use this file except in compliance with the License. 7 | REM You may obtain a copy of the License at 8 | REM 9 | REM http://www.apache.org/licenses/LICENSE-2.0 10 | REM 11 | REM Unless required by applicable law or agreed to in writing, software 12 | REM distributed under the License is distributed on an "AS IS" BASIS, 13 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | REM See the License for the specific language governing permissions and 15 | REM limitations under the License. 16 | REM 17 | 18 | SET CLASSPATH=%1;%CLASSPATH% 19 | -------------------------------------------------------------------------------- /src/jd/ide/intellij/config/JavaDecompilerConfigurationAccess.java: -------------------------------------------------------------------------------- 1 | package jd.ide.intellij.config; 2 | 3 | import com.intellij.openapi.application.ApplicationManager; 4 | 5 | /** 6 | * Java Decompiler configuration Access. 7 | * 8 | * @see JDPluginComponent 9 | */ 10 | public class JavaDecompilerConfigurationAccess { 11 | 12 | private final JDPluginComponent jdPluginComponent; 13 | 14 | public JavaDecompilerConfigurationAccess() { 15 | jdPluginComponent = ApplicationManager.getApplication().getComponent(JDPluginComponent.class); 16 | } 17 | 18 | public boolean isShowLineNumbersEnabled() { 19 | return jdPluginComponent.isShowLineNumbersEnabled(); 20 | } 21 | 22 | public boolean isShowMetadataEnabled() { 23 | return jdPluginComponent.isShowMetadataEnabled(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /starting/deapk.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM Deapk - A tools for "APK -> Eclipse Project" 5 | REM Copyright (c) 2013-2014 Jiongxuan Zhang 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx2048m -cp %CLASSPATH% "i.am.jiongxuan.deapk.MainApplication" %* 24 | -------------------------------------------------------------------------------- /src/jd/ide/intellij/JavaDecompilerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package jd.ide.intellij; 19 | 20 | public class JavaDecompilerService { 21 | // Nothing but native method requires it, usually used JNI reflections. 22 | // If you delete this file, it will appear ClassNotFoundException. 23 | } 24 | -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/ArchUtils.java: -------------------------------------------------------------------------------- 1 | package i.am.jiongxuan.deapk; 2 | 3 | import org.apache.commons.lang3.SystemUtils; 4 | 5 | /** 6 | * @author Jiongxuan Zhang 7 | */ 8 | public class ArchUtils { 9 | public static final boolean is32Bit() { 10 | return SystemUtils.OS_ARCH.equalsIgnoreCase("x86") // Windows 11 | || SystemUtils.OS_ARCH.equalsIgnoreCase("x86_32") // Mac 12 | || SystemUtils.OS_ARCH.equalsIgnoreCase("i386") // Linux 13 | || SystemUtils.OS_ARCH.equalsIgnoreCase("i486") 14 | || SystemUtils.OS_ARCH.equalsIgnoreCase("i586") 15 | || SystemUtils.OS_ARCH.equalsIgnoreCase("i686"); 16 | } 17 | 18 | public static final boolean is64Bit() { 19 | return SystemUtils.OS_ARCH.equalsIgnoreCase("x64") // Windows 20 | || SystemUtils.OS_ARCH.equalsIgnoreCase("x86_64") 21 | || SystemUtils.OS_ARCH.equalsIgnoreCase("amd64"); // Mac/Linux 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/com/intellij/openapi/fileTypes/ContentBasedClassFileProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.intellij.openapi.fileTypes; 19 | 20 | public interface ContentBasedClassFileProcessor { 21 | // Nothing but native method requires it, usually used JNI reflections. 22 | // If you delete this file, it will appear ClassNotFoundException. 23 | } 24 | -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/jd/core/DecompilerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package i.am.jiongxuan.deapk.jd.core; 19 | 20 | public class DecompilerException extends Exception { 21 | private static final long serialVersionUID = 5717520116795630375L; 22 | 23 | public DecompilerException(String message) { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/com/intellij/openapi/application/ApplicationManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.intellij.openapi.application; 19 | 20 | import com.intellij.openapi.application.Application; 21 | 22 | public class ApplicationManager { 23 | protected static Application app = new Application(); 24 | 25 | public static Application getApplication() { 26 | return app; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/com/intellij/openapi/components/ComponentManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.intellij.openapi.components; 19 | 20 | public interface ComponentManager { 21 | // Nothing but native method requires it, usually used JNI reflections. 22 | // If you delete this file, it will appear ClassNotFoundException. 23 | 24 | public T getComponent(Class interfaceClass); 25 | } 26 | -------------------------------------------------------------------------------- /src/jd/ide/intellij/JavaDecompilerClassFileProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package jd.ide.intellij; 19 | 20 | import com.intellij.openapi.fileTypes.ContentBasedClassFileProcessor; 21 | 22 | public class JavaDecompilerClassFileProcessor implements ContentBasedClassFileProcessor { 23 | // Nothing but native method requires it, usually used JNI reflections. 24 | // If you delete this file, it will appear ClassNotFoundException. 25 | } 26 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/jd/core/DecomplieEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package i.am.jiongxuan.deapk.jd.core; 19 | 20 | 21 | /** 22 | * @author Jiongxuan Zhang 23 | */ 24 | public class DecomplieEntry { 25 | private String mJavaPath; 26 | private String mContent; 27 | 28 | public DecomplieEntry(String javaPath, String content) { 29 | mJavaPath = javaPath; 30 | mContent = content; 31 | } 32 | 33 | public String getJavaPath() { 34 | return mJavaPath; 35 | } 36 | 37 | public String getContent() { 38 | return mContent; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /starting/deapk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Deapk - A tools for "APK -> Eclipse Project" 5 | # Copyright (c) 2013-2014 Jiongxuan Zhang 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx2048m -classpath "${_classpath}" "i.am.jiongxuan.deapk.MainApplication" "$@" 41 | -------------------------------------------------------------------------------- /src/com/intellij/openapi/application/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.intellij.openapi.application; 19 | 20 | import com.intellij.openapi.components.ComponentManager; 21 | import jd.ide.intellij.config.JDPluginComponent; 22 | 23 | public class Application implements ComponentManager { 24 | // Nothing but native method requires it, usually used JNI reflections. 25 | // If you delete this file, it will appear ClassNotFoundException. 26 | 27 | @SuppressWarnings("unchecked") 28 | public T getComponent(Class interfaceClass) { 29 | return (T)(new JDPluginComponent()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Eclipse Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | Contributors 20 | Jiongxuan Zhang - jiongj.zhang@gmail.com 21 | in Beijing, China 22 | 23 | We sincerely looking forward to your joining. 24 | 25 | 26 | Open source projects 27 | We used the following open source projects for your contribution to express my heartfelt gratitude! 28 | It can be said, without your project, perhaps no De-APK birth. 29 | 30 | apktool - It is a tool for reverse engineering 3rd party, closed, binary Android apps (resources, smalis) 31 | http://code.google.com/p/android-apktool/ 32 | 33 | dex2jar - Tools to work with android .dex and java .class files 34 | http://code.google.com/p/dex2jar/ 35 | 36 | jd-intellij - It allows you to display all the Java sources during your debugging process 37 | https://bitbucket.org/bric3/jd-intellij/overview -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/PercentWritter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package i.am.jiongxuan.deapk; 19 | 20 | /** 21 | * @author Jiongxuan Zhang 22 | * 23 | */ 24 | public class PercentWritter { 25 | private int mLastBits = 0; 26 | 27 | public void print(int current, int total) { 28 | String remove = getRemoveString(); 29 | 30 | String percentString = "(" + (int)(((double) current / total) * 100) 31 | + "%)"; 32 | mLastBits = percentString.length(); 33 | System.out.print(remove + percentString); 34 | } 35 | 36 | private String getRemoveString() { 37 | String remove = ""; 38 | for (int i = 0; i < mLastBits; i++) { 39 | remove += "\b"; 40 | } 41 | return remove; 42 | } 43 | 44 | public void end(boolean remove) { 45 | System.out.println(remove ? getRemoveString() : ""); 46 | mLastBits = 0; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/jd/core/Decompiler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package i.am.jiongxuan.deapk.jd.core; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | 23 | import jd.ide.intellij.JavaDecompiler; 24 | 25 | public class Decompiler { 26 | private JavaDecompiler mDecompiler; 27 | private File mJarPath; 28 | private DecomplieEnumeration mDecomplieEnumeration; 29 | 30 | public Decompiler(File jarPath) { 31 | mDecompiler = new JavaDecompiler(); 32 | mJarPath = jarPath; 33 | } 34 | 35 | public DecomplieEnumeration getEnumeration() throws IOException { 36 | if (mDecomplieEnumeration == null) { 37 | mDecomplieEnumeration = new DecomplieEnumeration(mDecompiler, mJarPath); 38 | } 39 | 40 | return mDecomplieEnumeration; 41 | } 42 | 43 | public int getCount() throws IOException { 44 | return getEnumeration().getCount(); 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/jd/ide/intellij/config/JDPluginComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package jd.ide.intellij.config; 19 | 20 | public class JDPluginComponent { 21 | private boolean escapeUnicodeCharactersEnabled; 22 | private boolean omitPrefixThisEnabled; 23 | private boolean realignLineNumbersEnabled; 24 | private boolean showLineNumbersEnabled; 25 | private boolean showMetadataEnabled; 26 | 27 | public boolean isEscapeUnicodeCharactersEnabled() { 28 | return escapeUnicodeCharactersEnabled; 29 | } 30 | 31 | public boolean isOmitPrefixThisEnabled() { 32 | return omitPrefixThisEnabled; 33 | } 34 | 35 | public boolean isRealignLineNumbersEnabled() { 36 | return realignLineNumbersEnabled; 37 | } 38 | 39 | public boolean isShowLineNumbersEnabled() { 40 | return showLineNumbersEnabled; 41 | } 42 | 43 | public boolean isShowMetadataEnabled() { 44 | return showMetadataEnabled; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | What is Deapk? 2 | ===== 3 | 4 | More information? [Click Here](http://jiongxuan.github.io/deapk/). 5 | 6 | Deapk is an open source tool that can directly decompile the APK files to Android project with only one step. 7 | 8 | * Drag APK to Deapk.bat (Windows only). Or 9 | 10 | * Input "deapk xxx.apk" in the command line (All platform supported) 11 | 12 | It is applied to Android platform, and the study and development personnel can use it. It is so simple that even the new learners can use it. 13 | 14 | It can be used in Windows, Linux and Mac system. 15 | 16 | Code 17 | ===== 18 | 19 | Deapk is an open source project which is developed for the users’ easy operation and relatively simple code implementation. The core is in the Deapk.java. 20 | 21 | Who am I? 22 | ===== 23 | 24 | I am a dreamer in pursuit of simplest way, loving technology and advocating combination of humanities, technology and art. Just like all of you, I also have been doing my endeavors on the long way chasing our dream. 25 | 26 | Perhaps you are also this kind of man who can not wait to change anything that has been found unreasonable and not perfect because you feel so miserable for this. We have to live in such an imperfect world, but we have the ability to change everything. 27 | 28 | Believe me, provision of the simplest and best service is just the first step in the long march. Although it is not great, it still has profound significance. In the near future, you will see more of my works, all of which will be arising from my interests. 29 | 30 | Please follow me and thanks for your consistent supports. 31 | 32 | Now I am working in the largest Internet security company in China - Qihoo 360, as Android software engineer. 33 | 34 | Email: JiongJ.Zhang@gmail.com 35 | 36 | Weibo(China):[@HaokeWorld](http://weibo.com/hihaoke) -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Eclipse Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | Deapk 2.0 19 | (21/11/2013) 20 | [FIX] Fix "IOUtils.close" crash for some reason. 21 | [FIX] Fix a bug that pop-up some useless dialog boxes. 22 | 23 | [OPT] Upgrade JD-Core to 0.7.0.1 24 | [OPT] Upgrade apktool 25 | 26 | Deapk 1.5 27 | (20/07/2013) 28 | [NEW] More convenient to view the Java code and Smali code 29 | 30 | [OPT] Upgrade to JDK 7.0 to enhance stability 31 | 32 | Deapk 1.2 33 | (06/07/2013) 34 | [NEW] Support for multiple files to deapk 35 | [OPT] Put decompile error into the error.txt file 36 | [OPT] Press 'y' to restart, otherwise to ignore if a Deapked project exists 37 | 38 | [FIX] After writing .classpath and .project, the XMLWriter did not close 39 | 40 | Deapk 1.0 41 | (30/06/2013) 42 | [NEW] You can generate standard Android Eclipse project 43 | [NEW] You can decompile all resource files, XML files, through apktool 1.5.2 44 | [NEW] You can decompile all class files, through dex2jar 0.0.9.11 45 | [NEW] You can decompile all Java source codes, through custom jd-intellij 46 | 47 | Deapk Beginning 48 | (15/06/2013) 49 | Write down the first line of code. 50 | -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/jd/core/DecomplieEnumeration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package i.am.jiongxuan.deapk.jd.core; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.util.Enumeration; 23 | import java.util.HashMap; 24 | import java.util.Iterator; 25 | import java.util.Map; 26 | import java.util.Map.Entry; 27 | import java.util.zip.ZipEntry; 28 | import java.util.zip.ZipFile; 29 | 30 | import jd.ide.intellij.JavaDecompiler; 31 | 32 | /** 33 | * @author Jiongxuan Zhang 34 | */ 35 | public class DecomplieEnumeration implements Enumeration { 36 | 37 | private JavaDecompiler mDecompiler; 38 | private File mJarPath; 39 | 40 | private Map mJavaToClassPathMap = new HashMap(); 41 | private Iterator> mIterator; 42 | 43 | public DecomplieEnumeration(JavaDecompiler decompiler, File jarPath) throws IOException { 44 | mDecompiler = decompiler; 45 | mJarPath = jarPath; 46 | 47 | ZipFile zipFile = new ZipFile(mJarPath); 48 | Enumeration enumeration = zipFile.entries(); 49 | while (enumeration.hasMoreElements()) { 50 | ZipEntry zipEntry = (ZipEntry) enumeration.nextElement(); 51 | String entryName = zipEntry.getName(); 52 | if (entryName.endsWith(".class")) { 53 | String classPath = entryName.replaceAll("\\$.*\\.class$", ".class"); 54 | String javaPath = classPath.toString().replaceAll("\\.class$", ".java"); 55 | if (!mJavaToClassPathMap.containsKey(javaPath)) { 56 | mJavaToClassPathMap.put(javaPath, classPath); 57 | } 58 | } 59 | } 60 | zipFile.close(); 61 | 62 | mIterator = mJavaToClassPathMap.entrySet().iterator(); 63 | } 64 | 65 | @Override 66 | public boolean hasMoreElements() { 67 | return mIterator.hasNext(); 68 | } 69 | 70 | @Override 71 | public DecomplieEntry nextElement() { 72 | while (mIterator.hasNext()) { 73 | Entry entry = (Entry) mIterator.next(); 74 | String javaPath = entry.getKey(); 75 | String classPath = entry.getValue(); 76 | String content = mDecompiler.decompile(mJarPath.toString(), classPath.toString()); 77 | return new DecomplieEntry(javaPath, content); 78 | } 79 | 80 | return null; 81 | } 82 | 83 | public int getCount() { 84 | return mJavaToClassPathMap.size(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/jd/ide/intellij/JavaDecompiler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package jd.ide.intellij; 19 | 20 | import i.am.jiongxuan.deapk.ArchUtils; 21 | 22 | import java.io.File; 23 | import java.io.UnsupportedEncodingException; 24 | 25 | import org.apache.commons.lang3.SystemUtils; 26 | 27 | /** 28 | * Java Decompiler tool, use native libs to achieve decompilation. 29 | *

30 | *

31 | * Identify the native lib full path through IntelliJ helpers in {@link SystemInfo}. 32 | *

33 | */ 34 | public class JavaDecompiler { 35 | 36 | public static String JD_LIB_RELATIVE_PATH = "lib" + File.separator + "jd-core" + File.separator + osIdentifier() 37 | + File.separator + architecture() + File.separator + libFileName(); 38 | 39 | public JavaDecompiler() { 40 | String pluginPath = JavaDecompiler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); 41 | try { 42 | pluginPath = java.net.URLDecoder.decode(pluginPath, "UTF-8"); 43 | } catch (UnsupportedEncodingException e) { 44 | e.printStackTrace(); 45 | } 46 | pluginPath = new File(pluginPath).getParent(); 47 | 48 | String libPath = pluginPath + File.separator + JD_LIB_RELATIVE_PATH; 49 | loadLibrary(pluginPath, libPath); 50 | } 51 | 52 | private void loadLibrary(String pluginPath, String libPath) { 53 | try { 54 | System.load(libPath); 55 | } catch (Exception e) { 56 | throw new IllegalStateException("Something got wrong when loading the Java Decompiler native lib, " 57 | + "\nlookup path : " + libPath + "\nplugin path : " + pluginPath, e); 58 | } 59 | } 60 | 61 | /** 62 | * Library filename, depending on the OS identifier. 63 | * 64 | * @return lib filename. 65 | */ 66 | private static String libFileName() { 67 | if (SystemUtils.IS_OS_MAC_OSX) { 68 | return "libjd-intellij.jnilib"; 69 | } else if (SystemUtils.IS_OS_WINDOWS) { 70 | return "jd-intellij.dll"; 71 | } else if (SystemUtils.IS_OS_LINUX) { 72 | return "libjd-intellij.so"; 73 | } 74 | throw new IllegalStateException("OS not supported"); 75 | } 76 | 77 | /** 78 | * Architecture, either 32bit or 64bit. 79 | * 80 | * @return x86 or x86_64 for respectively 32bit 64bit architecture. 81 | */ 82 | private static String architecture() { 83 | if (ArchUtils.is32Bit()) { 84 | return "x86"; 85 | } else if (ArchUtils.is64Bit()) { 86 | return "x86_64"; 87 | } 88 | throw new IllegalStateException("Unsupported architecture, only x86 and x86_64 architectures are supported."); 89 | } 90 | 91 | /** 92 | * Identify the OS. 93 | * 94 | * @return Either macosx, win32, linux 95 | */ 96 | private static String osIdentifier() { 97 | if (SystemUtils.IS_OS_MAC_OSX) { 98 | return "macosx"; 99 | } else if (SystemUtils.IS_OS_WINDOWS) { 100 | return "win32"; 101 | } else if (SystemUtils.IS_OS_LINUX) { 102 | return "linux"; 103 | } 104 | throw new IllegalStateException("Unsupported OS, only windows, linux and mac OSes are supported."); 105 | } 106 | 107 | /** 108 | * Actual call to the native lib. 109 | * 110 | * @param basePath 111 | * Path to the root of the classpath, either a path to a 112 | * directory or a path to a jar file. 113 | * @param internalClassName 114 | * internal name of the class. 115 | * @return Decompiled class text. 116 | */ 117 | public native String decompile(String basePath, String internalClassName); 118 | } 119 | -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/MainApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package i.am.jiongxuan.deapk; 19 | 20 | import java.io.BufferedReader; 21 | import java.io.IOException; 22 | import java.io.InputStreamReader; 23 | import java.util.ArrayList; 24 | import java.util.Date; 25 | import java.util.List; 26 | 27 | /** 28 | * @author Jiongxuan Zhang 29 | */ 30 | public class MainApplication { 31 | 32 | public static void main(String[] args) { 33 | System.out.println(); 34 | System.out.println("===================================================================="); 35 | System.out.println(); 36 | System.out 37 | .println(" Welcome to choose Deapk by Jiongxuan (Version: 2.0)"); 38 | System.out.println(" The most convenient source decompiling tool by far."); 39 | System.out.println(); 40 | System.out 41 | .println(" Decompile the APK files to Android project"); 42 | System.out.println(" with only ONE STEP."); 43 | System.out.println(); 44 | System.out.println("===================================================================="); 45 | 46 | if (args.length < 1) { 47 | usage(); 48 | return; 49 | } 50 | 51 | List vaildFileList = new ArrayList(); 52 | for (String file : args) { 53 | if (file.endsWith(".apk")) { 54 | vaildFileList.add(file); 55 | } 56 | } 57 | 58 | if (vaildFileList.size() < 1) { 59 | usage(); 60 | return; 61 | } 62 | 63 | boolean hasSucceed = false; 64 | 65 | for (int i = 0; i < vaildFileList.size(); i++) { 66 | System.out.println(); 67 | System.out.println(">>> Starting Deapk now!" + "(" + (i + 1) + "/" + vaildFileList.size() + ")"); 68 | System.out.println(" This may take a few seconds to complete."); 69 | System.out.println(); 70 | 71 | String vaildFile = vaildFileList.get(i); 72 | Deapk deapk = new Deapk(vaildFile); 73 | if (deapkNow(deapk)) { 74 | System.out.println(); 75 | System.out.println(">>> Deapked the " + deapk.getProjectNameIfExists() + " project complete!"); 76 | hasSucceed = true; 77 | } 78 | } 79 | 80 | if (hasSucceed) { 81 | System.out.println(); 82 | System.out.println("Congratulations!"); 83 | System.out.println("You have successfully Deapked these projects, and now " + 84 | "you can open Eclipse and import it directly through the path \"File -> Import\"."); 85 | System.out.println("Then you can enjoy the fun as a \"hacker\" to the full!"); 86 | } 87 | 88 | help(); 89 | waitFor(); 90 | } 91 | 92 | private static boolean deapkNow(Deapk deapk) { 93 | if (!deapk.isApkExists()) { 94 | System.out.println("!!! ERROR: No such a file: " + deapk.getApkPath()); 95 | return false; 96 | } 97 | 98 | if (deapk.isProjectExists()) { 99 | String date = ""; 100 | long nowDays = new Date().getTime() / 1000 / 60 / 60 / 24; 101 | long projectDays = deapk.getLastDate().getTime() / 1000 / 60 / 60 / 24; 102 | long betweenDays = nowDays - projectDays; 103 | if (betweenDays <= 0) { 104 | date = "today"; 105 | } else if (betweenDays == 1){ 106 | date = "yesterday"; 107 | } else if (betweenDays <= 100){ 108 | date = betweenDays + " days before"; 109 | } else { 110 | date = "a long time before"; 111 | } 112 | System.out.println("??? Question for you: "); 113 | System.out.println("??? File path: " + deapk.getApkPath()); 114 | System.out.println("???"); 115 | System.out.println("??? This project has been Deapked " + date + "."); 116 | System.out.println("??? Please confirm whether it will be redone?"); 117 | System.out.println("??? Press 'y' to restart, otherwise to ignore."); 118 | 119 | String response = ""; 120 | BufferedReader strin = new BufferedReader(new InputStreamReader(System.in)); 121 | try { 122 | response = strin.readLine(); 123 | } catch (IOException e) { 124 | e.printStackTrace(); 125 | } 126 | 127 | if (response.isEmpty() 128 | || response.substring(0, 1).compareToIgnoreCase("y") != 0) { 129 | return false; 130 | } 131 | } 132 | 133 | return deapk.start(); 134 | } 135 | 136 | private static void help() { 137 | System.out.println(); 138 | System.out 139 | .println("If you want to learn more exciting details and the latest developments about Deapk, please visit this site at any time:"); 140 | System.out.println(); 141 | System.out.println(" http://jiongxuan.github.io/deapk/"); 142 | System.out.println(); 143 | } 144 | 145 | public static void waitFor() { 146 | System.out.print("Press enter to exit..."); 147 | try { 148 | System.in.read(); 149 | } catch (IOException e) { 150 | e.printStackTrace(); 151 | } 152 | } 153 | 154 | private static void usage() { 155 | System.out.println(); 156 | System.out.println("Usage:"); 157 | System.out.println(" deapk "); 158 | System.out.println(); 159 | System.out.println("Support for multiple files to deapk. Just like:"); 160 | System.out.println(" deapk <*.apk>..."); 161 | System.out.println(); 162 | System.out.println("i.e."); 163 | System.out.println(" deapk haoke.apk"); 164 | System.out.println(" deapk sin.apk cos.apk tan.apk"); 165 | System.out.println(" deapk *.apk"); 166 | System.out.println(); 167 | System.out.println("So easy, right?"); 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/GenerateProjectOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package i.am.jiongxuan.deapk; 19 | 20 | 21 | import java.io.File; 22 | import java.io.FileNotFoundException; 23 | import java.io.FileOutputStream; 24 | import java.io.IOException; 25 | import java.io.UnsupportedEncodingException; 26 | 27 | import org.apache.commons.io.FileUtils; 28 | import org.dom4j.Document; 29 | import org.dom4j.DocumentException; 30 | import org.dom4j.DocumentHelper; 31 | import org.dom4j.Element; 32 | import org.dom4j.io.SAXReader; 33 | import org.dom4j.io.XMLWriter; 34 | 35 | /** 36 | * @author Jiongxuan Zhang 37 | */ 38 | public class GenerateProjectOperator { 39 | private File mProjectFile; 40 | private String mProjectName; 41 | 42 | public GenerateProjectOperator(File projectFile) { 43 | mProjectFile = projectFile; 44 | } 45 | 46 | public void generateGenDir() { 47 | File genDir = new File(mProjectFile, "gen"); 48 | if (!genDir.exists()) { 49 | genDir.mkdirs(); 50 | } 51 | } 52 | 53 | public void genereateProjectPropertiesFile() { 54 | StringBuilder projectBuilder = new StringBuilder(); 55 | projectBuilder.append("target=android-17"); 56 | try { 57 | FileUtils.write(new File(mProjectFile, "project.properties"), projectBuilder.toString()); 58 | } catch (FileNotFoundException e) { 59 | e.printStackTrace(); 60 | } catch (IOException e) { 61 | e.printStackTrace(); 62 | } 63 | } 64 | 65 | public void generateClassPathFile() { 66 | Document document = DocumentHelper.createDocument(); 67 | Element classPathElement = document.addElement("classpath"); 68 | classPathElement.addElement("classpathentry") 69 | .addAttribute("kind", "src").addAttribute("path", "src"); 70 | classPathElement.addElement("classpathentry") 71 | .addAttribute("kind", "src").addAttribute("path", "gen"); 72 | classPathElement 73 | .addElement("classpathentry") 74 | .addAttribute("kind", "con") 75 | .addAttribute("path", 76 | "com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"); 77 | classPathElement.addElement("classpathentry") 78 | .addAttribute("kind", "con") 79 | .addAttribute("path", "com.android.ide.eclipse.adt.LIBRARIES"); 80 | classPathElement 81 | .addElement("classpathentry") 82 | .addAttribute("kind", "con") 83 | .addAttribute("path", 84 | "com.android.ide.eclipse.adt.DEPENDENCIES") 85 | .addAttribute("exported", "true"); 86 | classPathElement.addElement("classpathentry") 87 | .addAttribute("kind", "output") 88 | .addAttribute("path", "bin/classes"); 89 | 90 | try { 91 | XMLWriter xmlWriter = new XMLWriter(new FileOutputStream( 92 | new File(mProjectFile, ".classpath"))); 93 | xmlWriter.write(document); 94 | xmlWriter.close(); 95 | } catch (UnsupportedEncodingException e) { 96 | e.printStackTrace(); 97 | } catch (FileNotFoundException e) { 98 | e.printStackTrace(); 99 | } catch (IOException e) { 100 | e.printStackTrace(); 101 | } 102 | } 103 | 104 | public void generateProjectFile() { 105 | Document document = DocumentHelper.createDocument(); 106 | Element projectDescriptionElement = document 107 | .addElement("projectDescription"); 108 | projectDescriptionElement.addElement("name").addText( 109 | getProjectNameInManifestXml()); 110 | 111 | Element buildSpecElement = projectDescriptionElement 112 | .addElement("buildSpec"); 113 | buildSpecElement.addElement("buildCommand").addElement("name") 114 | .addText("com.android.ide.eclipse.adt.ResourceManagerBuilder"); 115 | buildSpecElement.addElement("buildCommand").addElement("name") 116 | .addText("com.android.ide.eclipse.adt.PreCompilerBuilder"); 117 | buildSpecElement.addElement("buildCommand").addElement("name") 118 | .addText("org.eclipse.jdt.core.javabuilder"); 119 | buildSpecElement.addElement("buildCommand").addElement("name") 120 | .addText("com.android.ide.eclipse.adt.ApkBuilder"); 121 | 122 | Element naturesElement = projectDescriptionElement 123 | .addElement("natures"); 124 | naturesElement.addElement("nature").addText( 125 | "com.android.ide.eclipse.adt.AndroidNature"); 126 | naturesElement.addElement("nature").addText( 127 | "org.eclipse.jdt.core.javanature"); 128 | 129 | try { 130 | XMLWriter xmlWriter = new XMLWriter(new FileOutputStream( 131 | new File(mProjectFile, ".project"))); 132 | xmlWriter.write(document); 133 | xmlWriter.close(); 134 | } catch (UnsupportedEncodingException e) { 135 | e.printStackTrace(); 136 | } catch (FileNotFoundException e) { 137 | e.printStackTrace(); 138 | } catch (IOException e) { 139 | e.printStackTrace(); 140 | } 141 | } 142 | 143 | public String getProjectName() { 144 | return mProjectName; 145 | } 146 | 147 | public String getProjectNameInManifestXml() { 148 | if (mProjectName == null) { 149 | String packageName = ""; 150 | String versionName = ""; 151 | String versionCode = ""; 152 | 153 | File inputXml = new File(mProjectFile, "AndroidManifest.xml"); 154 | SAXReader saxReader = new SAXReader(); 155 | try { 156 | Document document = saxReader.read(inputXml); 157 | Element manifestElement = document.getRootElement(); 158 | packageName = manifestElement.attributeValue("package"); 159 | versionName = manifestElement.attributeValue("versionName"); 160 | versionCode = manifestElement.attributeValue("versionCode"); 161 | } catch (DocumentException e) { 162 | e.printStackTrace(); 163 | } 164 | 165 | mProjectName = packageName.substring(packageName.lastIndexOf('.') + 1) + "_" 166 | + versionName + "-" + versionCode; 167 | } 168 | 169 | return mProjectName; 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /src/i/am/jiongxuan/deapk/Deapk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Deapk - A tools for "APK -> Android Project" 3 | * Copyright (c) 2013-2014 Jiongxuan Zhang 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package i.am.jiongxuan.deapk; 19 | 20 | import i.am.jiongxuan.deapk.jd.core.Decompiler; 21 | import i.am.jiongxuan.deapk.jd.core.DecomplieEntry; 22 | import i.am.jiongxuan.deapk.jd.core.DecomplieEnumeration; 23 | 24 | import java.io.File; 25 | import java.io.FileWriter; 26 | import java.io.IOException; 27 | import java.util.ArrayList; 28 | import java.util.Collections; 29 | import java.util.Date; 30 | import java.util.List; 31 | import java.util.Map; 32 | import java.util.logging.Level; 33 | import java.util.logging.Logger; 34 | 35 | import org.apache.commons.io.FileUtils; 36 | import org.apache.commons.io.FilenameUtils; 37 | 38 | import brut.androlib.Androlib; 39 | import brut.androlib.AndrolibException; 40 | import brut.androlib.ApkDecoder; 41 | import brut.androlib.res.AndrolibResources; 42 | import brut.androlib.res.util.ExtFile; 43 | 44 | import com.googlecode.dex2jar.Method; 45 | import com.googlecode.dex2jar.reader.DexFileReader; 46 | import com.googlecode.dex2jar.v3.Dex2jar; 47 | import com.googlecode.dex2jar.v3.DexExceptionHandlerImpl; 48 | 49 | /** 50 | * @author Jiongxuan Zhang 51 | */ 52 | public class Deapk { 53 | private final File mApkDir; 54 | private final File mProjectDir; 55 | private final File mClassesDexFile; 56 | private final File mClassesJarFile; 57 | private final File mClassesJarErrorFile; 58 | private final File mErrorFile; 59 | private final File mSrcDir; 60 | private final File mSmaliDir; 61 | 62 | private final GenerateProjectOperator mGenerateProjectOperator; 63 | 64 | public Deapk(String apkPath) { 65 | mApkDir = new File(apkPath); 66 | 67 | String apkName = FilenameUtils.getName(apkPath); 68 | String projectName = apkName.substring(0, apkName.lastIndexOf('.')); 69 | mProjectDir = new File(mApkDir.getParentFile(), projectName + "_project"); 70 | 71 | mClassesDexFile = new File(mProjectDir, "classes.dex"); 72 | mClassesJarFile = new File(mProjectDir, "classes.jar"); 73 | mClassesJarErrorFile = new File(mProjectDir, "classes-error.zip"); 74 | mErrorFile = new File(mProjectDir, "error.txt"); 75 | mSrcDir = new File(mProjectDir, "src"); 76 | mSmaliDir = new File(mProjectDir, "smali"); 77 | 78 | mGenerateProjectOperator = new GenerateProjectOperator(mProjectDir); 79 | } 80 | 81 | public File getApkPath() { 82 | return mApkDir; 83 | } 84 | 85 | public boolean isApkExists() { 86 | return mApkDir.exists(); 87 | } 88 | 89 | public boolean isProjectExists() { 90 | return mProjectDir.exists(); 91 | } 92 | 93 | public Date getLastDate() { 94 | return new Date(mProjectDir.lastModified()); 95 | } 96 | 97 | public File getProjectPath() { 98 | return mProjectDir; 99 | } 100 | 101 | public String getProjectNameIfExists() { 102 | return mGenerateProjectOperator.getProjectName(); 103 | } 104 | 105 | public boolean start() { 106 | if (isProjectExists()) { 107 | System.out.println(">>> (0/5) Cleaning..."); 108 | try { 109 | FileUtils.deleteDirectory(getProjectPath()); 110 | } catch (Exception e) { 111 | e.printStackTrace(); 112 | return false; 113 | } 114 | } 115 | 116 | return decodeResources() && extractAll() && decodeToClassDex() && decodeToJavaCodes() 117 | && writeEclipseProjectFiles(); 118 | } 119 | 120 | public boolean decodeResources() { 121 | System.out.println(">>> (1/5) Decompiling all resource files and smali files..."); 122 | 123 | Logger.getLogger(AndrolibResources.class.getName()).setLevel(Level.OFF); 124 | Logger.getLogger(Androlib.class.getName()).setLevel(Level.OFF); 125 | ApkDecoder apkDecoder = new ApkDecoder(); 126 | try { 127 | apkDecoder.setKeepBrokenResources(true); 128 | apkDecoder.setBaksmaliDebugMode(false); 129 | apkDecoder.setDebugMode(false); 130 | apkDecoder.setOutDir(mProjectDir); 131 | apkDecoder.setApkFile(mApkDir); 132 | apkDecoder.decode(); 133 | } catch (AndrolibException e) { 134 | e.printStackTrace(); 135 | return false; 136 | } catch (IOException e) { 137 | e.printStackTrace(); 138 | return false; 139 | } 140 | 141 | if (mSmaliDir.exists()) { 142 | try { 143 | FileUtils.moveDirectory(mSmaliDir, mSrcDir); 144 | } catch (IOException e) { 145 | e.printStackTrace(); 146 | // Rename the smali to src is not required, skip it if error. 147 | } 148 | } 149 | 150 | return true; 151 | } 152 | 153 | public boolean extractAll() { 154 | System.out.println(">>> (2/5) Extracting files..."); 155 | try { 156 | ExtFile zipFile = new ExtFile(mApkDir); 157 | zipFile.getDirectory().copyToDir(mProjectDir); 158 | return true; 159 | 160 | } catch (Exception e) { 161 | e.printStackTrace(); 162 | } 163 | return false; 164 | } 165 | 166 | public boolean decodeToClassDex() { 167 | System.out.print(">>> (3/5) Generating all Java Class files..."); 168 | 169 | try { 170 | DexFileReader reader = new DexFileReader(mClassesDexFile); 171 | 172 | int count = reader.getClassSize(); 173 | String remain = "(Estimate " + (count / 100) + " seconds)"; 174 | System.out.print(remain); 175 | 176 | DexExceptionHandlerImpl handler = new DexExceptionHandlerImpl().skipDebug(true); 177 | 178 | Dex2jar.from(reader).withExceptionHandler(handler).reUseReg(true).topoLogicalSort(true).skipDebug(true) 179 | .optimizeSynchronized(true).printIR(false).verbose(false).to(mClassesJarFile.toString()); 180 | 181 | if (handler != null) { 182 | Map exceptions = handler.getExceptions(); 183 | if (exceptions != null && exceptions.size() > 0) { 184 | File errorFile = mClassesJarErrorFile; 185 | handler.dumpException(reader, errorFile); 186 | } 187 | } 188 | 189 | String remove = ""; 190 | for (int i = 0; i < remain.length(); i++) { 191 | remove += "\b"; 192 | } 193 | System.out.println(remove); 194 | return true; 195 | } catch (IOException e) { 196 | e.printStackTrace(); 197 | } 198 | 199 | return false; 200 | } 201 | 202 | public boolean decodeToJavaCodes() { 203 | System.out.print(">>> (4/5) Generating all Java source code files..."); 204 | 205 | Decompiler decompiler = new Decompiler(mClassesJarFile); 206 | ArrayList failureList = new ArrayList(); 207 | DecomplieEnumeration enumeration; 208 | try { 209 | enumeration = decompiler.getEnumeration(); 210 | } catch (IOException e) { 211 | e.printStackTrace(); 212 | return false; 213 | } 214 | 215 | PercentWritter percentWritter = new PercentWritter(); 216 | int count = enumeration.getCount(); 217 | int current = 0; 218 | while (enumeration.hasMoreElements()) { 219 | percentWritter.print(current, count); 220 | try { 221 | DecomplieEntry entry = (DecomplieEntry) enumeration.nextElement(); 222 | if (entry != null) { 223 | String relativePath = entry.getJavaPath(); 224 | File saveFile = new File(mSrcDir, relativePath); 225 | File saveParentDir = saveFile.getParentFile(); 226 | if (!saveParentDir.exists()) { 227 | saveParentDir.mkdirs(); 228 | } 229 | 230 | String source = entry.getContent(); 231 | if (source != null && source != "") { 232 | FileUtils.write(saveFile, source); 233 | } else { 234 | failureList.add(relativePath.toString()); 235 | } 236 | } 237 | } catch (Exception e) { 238 | e.printStackTrace(); 239 | } 240 | 241 | current++; 242 | } 243 | percentWritter.end(true); 244 | 245 | if (failureList.size() > 0) { 246 | Collections.sort(failureList); 247 | writeError("Unable to decompile these files:", failureList); 248 | } 249 | 250 | String printString = String.format( 251 | " Decompiled %d java source files, succeed %d files, error %d files", count, count 252 | - failureList.size(), failureList.size()); 253 | System.out.println(printString); 254 | 255 | return true; 256 | } 257 | 258 | private void writeError(String errorTitle, List errors) { 259 | try { 260 | FileWriter errorWriter = new FileWriter(mErrorFile); 261 | errorWriter.write(errorTitle + "\r\n"); 262 | 263 | for (String error : errors) { 264 | errorWriter.write(" " + error + "\r\n"); 265 | } 266 | 267 | if (errorWriter != null) { 268 | errorWriter.close(); 269 | } 270 | } catch (IOException e) { 271 | e.printStackTrace(); 272 | } 273 | } 274 | 275 | private boolean writeEclipseProjectFiles() { 276 | System.out.println(">>> (5/5) Creating a new Android project..."); 277 | mGenerateProjectOperator.generateGenDir(); 278 | mGenerateProjectOperator.genereateProjectPropertiesFile(); 279 | mGenerateProjectOperator.generateClassPathFile(); 280 | mGenerateProjectOperator.generateProjectFile(); 281 | 282 | return true; 283 | } 284 | } 285 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright (c) 2013-2014 Jiongxuan Zhang 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | --------------------------------------------------------------------------------