Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

adt - Blank activity not getting created using New->Android Activity Wizard

I had recently updated my Android SDK from 22.3 to 22.6. After updating, i tried creating a Blank Activity using the wizard. I am unable to create one as i used to create earlier. Also,i am unable to create LoginActivity, or Settings Activity etc.

I somehow managed to create the Activity through wizard, i found that instead of extending simple Activity, my class was extending something else.

Did anyone else faced such a problem?

Please help me out in this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have not suffer this problem with 22.6 but with 23. In my case, the problem seems to be the free maker sintax of the .flt files of the template.

Just in case this could be useful to others, I've solved this issue changing two files:

$ANDROID_SDK/tools/templates/activities/BlankActivity/recipe.xml.ftl original:

<?xml version="1.0"?>
<recipe>
    <#if appCompat><dependency mavenUrl="com.android.support:appcompat-v7:19.+"/></#if>
    ...

I've added ?has_content after <#if appCompat in line 4:

<?xml version="1.0"?>
<recipe>
    <#if appCompat?has_content><dependency mavenUrl="com.android.support:appcompat-v7:19.+"/></#if>
    ...

The other file is $ANDROID_SDK/tools/templates/activities/BlankActivity/root/res/menu/main.xml.ftl. The original version starts with:

<menu xmlns:android="http://schemas.android.com/apk/res/android"<#if appCompat>
...

I've added the same string at the end:

<menu xmlns:android="http://schemas.android.com/apk/res/android"<#if appCompat?has_content>
...

The same errors exist in many other activities templates...

Keep in mind that these changes will be overwriten with the next SDK update... I hope Google solve this issue, because developping for Android with Eclipse is becoming a headache.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...