Android/Cyanogenmod building: remove-project from roomservice.xml - android

I want to remove a device-related project from the roomservice.xml generated by brunching in CM and add a different repo myself.
Theoretically (in my localmanifest, called mint.xml), I should just need to
<remove-project name="Cyanogenmod/....
But repo sync tells me that
remove-project element specifies non-existant project
Is that because my local manifest is sourced before the roomservice.xml?
The question is a bit related to this one:
trouble-with-cyanogenmod-local-manifest
Additional sources:
CM Wiki about removing projects
Do you know how to source the own manifest after the roomservice.xml or somehow achieve the same?
Thanks for any answers.

As seen in Repo's manifest_xml.py,
LOCAL_MANIFESTS_DIR_NAME = 'local_manifests'
...
class XmlManifest(object):
...
def _Load(self):
...
local_dir = os.path.abspath(os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME))
try:
for local_file in sorted(os.listdir(local_dir)):
if local_file.endswith('.xml'):
local = os.path.join(local_dir, local_file)
nodes.append(self._ParseManifestXml(local, self.repodir))
except OSError:
pass
local manifest files are read in alphabetical order. Your file mint.xml is therefore loaded before roomservice.xml, so at the time you try to remove the project that's defined in roomservice.xml it doesn't actually exist. Rename your file to something that sorts after roomservice.xml.

Related

Use Sample data directory from a library

I created Sample data directory for my Android app using the process described in this article. I would like to share this set of sample data between my projects, so I created a library that only has sample data inside. But as far as I can see sampledata folder is not being compiled into the library. Is there a way to share sample data between multiple Android projects?
As already said, you can't do that with a library because sampledata simply can't be part of an Android library.
One thing you could though, host your names file somewhere and then fetch it with a gradle task, you could just add to an app's build.gradle
clean.doFirst {
println "cleanSamples"
def samplesDir = new File(projectDir.absolutePath, "sampledata")
if (samplesDir.exists()) {
samplesDir.deleteDir()
}
}
task fetchSamples {
println "fetchSamples"
def samplesDir = new File(projectDir.absolutePath, "sampledata")
if (samplesDir.exists()) {
println "samples dir already exists"
return
}
samplesDir.mkdir()
def names = new File(samplesDir, "names")
new URL('http://path/to/names').withInputStream { i ->
names.withOutputStream {
it << i
}
}
}
You can see 2 functions there, the first one is run before a clean task and it will just delete your sampledata folder. The second one is a task run on every build, it won't download the file every time but only if the directory is not there.
I understand you might as well copy paste names file, but, with this method you need to copy paste the tasks only once and you would be able to change names in any project just by uploading a new file and doing a clean build.
The short answer is no, you can't do that with sampledata folder. Basically, the format of the Android Libraries is AAR. If you reference the official documentation, it says that:
The file itself is a zip file containing the following mandatory entries:
/AndroidManifest.xml
/classes.jar
/res/
/R.txt
/public.txt
Additionally, an AAR file may include one or more of the following optional entries:
/assets/
/libs/name.jar
/jni/abi_name/name.so (where abi_name is one of the Android supported ABIs)
/proguard.txt
/lint.jar
So, sampledata can't be a part of AAR library.
UPDATE
Instead of your own data samples, you can use predefined sample resources. For example #tools:sample/first_names will randomly select from some common first names, eg., Sophia, Jacob, Ivan.
Example of usage:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="#tools:sample/first_names" />

Is it possible to manually edit settings.gradle file?

In a Cordova project, I have a file settings.gradle which looks like:
// GENERATED FILE - DO NOT EDIT
include ":"
include ":CordovaLib"
However, manually I want to edit the file and to make it look something like:
// GENERATED FILE - DO NOT EDIT
include ":"
include ":CordovaLib"
include 'manager-A'
project(':manager-A').projectDir = new File('libs/Manager-A')
include 'manager-B'
project(':manager-B').projectDir = new File('libs/Manager-B')
The above script looks good and it can be built successfully using Android studio. However, when I try to execute command line: cordova build android, it cannot be built.
The error is 'manager-A' and 'manager-B' that I manually included earlier cannot be found by the command line. After checking, it turned out that the file that I manually edited was re-generated and it becomes:
// GENERATED FILE - DO NOT EDIT
include ":"
include ":CordovaLib"
I'd like to ask whether it is possible to manually edit the file and that can be built as I explained above using the command line: cordova build android.
Any input is really appreciated!
Yes, I was looking to resolve same problem and found out following solution from this npm cordova-blinkup-plugin's Page. You can edit the settings with as:
1. Open path/to/project/platforms/android/cordova/lib/build.js
2. Edit fs.writeFileSync() function (line 273):
// Write the settings.gradle file.
fs.writeFileSync(path.join(projectPath, 'settings.gradle'),
'// GENERATED FILE - DO NOT EDIT\n' +
'include ":"\n' + settingsGradlePaths.join('') +
'include ":customProject1" +
'include ":customProject2"');
I hope this will help.
Update as suggested in another answer, In newer versions of Cordova you may get file at
/path/to/project/platforms/android/cordova/lib/builders/GradleBuilder.js
I found a better way to add custom include in setting.gradle file.
Make a file project.properties and add the below lines:
target=android-22
android.library.reference.1=CordovaLib
android.library.reference.2=manager-A
android.library.reference.3=manager-B
Now run cordova build android. This will make an entry in your setting.gradle file.
This answers part of the questions of how to include a module. But how to add the libs as below, still need a better way:
project(':manager-A').projectDir = new File('libs/Manager-A')
Can be done with modifying the build.js (Suggested by Sopheak Mongkul). I don't recommend, but it is good till you get a better solution.
An update to #ankibalyan's answer:
I found that function in path/to/project/platforms/android/cordova/lib/builders/GradleBuilder.js, just in case anybody needed it any more :)

greenDAO schema generation with relative output path; failing with i/o not found

Following along with this tutorial, I've been able to create a working app module that compiles and runs, but fails if I pass a relative path to the generateAll method. It works fine if I specify an absolute path. My android studio project is composed of a few modules, structured like
project_root, with sub directories for each of it's modules
/daogenerator
/app
Each has it's own src directories, and I'm calling the generateAll like:
new DaoGenerator().generateAll(schema,
"../app/src");
which results in an io error, indicating that the directory doesn't exist. I've modified the path to many reasonable alternatives, and confirmed that the paths exist on disk, but still getting the error. The absolute path works fine, so I'm trying to understand what I'm missing to get it working with a relative path. Thanks.
The outDir parameter is expected to be relative to the project directory.
For example, suppose your MyDaoGenerator class is in module1 under projectA and you want to generate the DAO classes into a separate module2 of the same project ...
projectA
module1/
src/main/java/com.my.package/MyDaoGenerator.java
module2/
src/main/java/ <-- target directory
... the outDir parameter would be module2/src/main/java.
In my case I had to change the package to this
new DaoGenerator().generateAll(schema, "app/src/main/java");
from this
new DaoGenerator().generateAll(schema, "../app/src/main/java");
Perhaps you could check the run configurations.
If your dao generator code is in a class named M.java, you can edit the run configuration for it:
Then you should ensure that it is pointing to the right working directory:
Finally, we can generate the dao code:
public static void main(String[] args) throws Exception
{
...
new DaoGenerator().generateAll(schema, "."); // direct to working directory
}
It worked for me. Hope it help.
Source: this tutorial

Cannot compile system app (Phone) using maven - EventLogTags cannot be resolved

this is related to my previous question. I'm trying to build Phone application from android 4.0.4 using maven (I'm adding framework_intermediates as dependency, so internal apis problems are solved), and I ran into this problem. Some parts of the logs are as follows:
Phone/src/com/android/phone/CallNotifier.java:[601,32] cannot find symbol
symbol : variable EventLogTags
(the corresponding line in CallNotifier.java is: EventLog.writeEvent(EventLogTags.PHONE_UI_MULTIPLE_QUERY); )
Phone/src/com/android/phone/InCallScreen.java:[723,28] cannot find symbol
symbol : variable EventLogTags
(the corresponding line in InCallScreen.java is: EventLog.writeEvent(EventLogTags.PHONE_UI_ENTER); )
So... it cannot find the class EventLogTags. There is actually a file Phone/src/com/android/phone/EventLogTags.logtags which has the following contents:
# See system/core/logcat/event.logtags for a description of the format of this file.
option java_package com.android.phone;
70301 phone_ui_enter
70302 phone_ui_exit
70303 phone_ui_button_click (text|3)
70304 phone_ui_ringer_query_elapsed
70305 phone_ui_multiple_query
Apparently, this file tells the system to use some particular tags to log important events in the system. I did a full grep, but could not find any file which defines the values PHONE_UI_ENTER, PHONE_UI_MULTIPLE_QUERY, etc. These are just logs, so I could just comment out these and get it working. But I don't want to do this because I need to build this inside the entire aosp later on. So my question is, how do I get this to compile using maven, without modifying any file?
The Android build system code-generates a Java class out of .logtags files if needed. See: https://github.com/android/platform_build/blob/master/core/base_rules.mk
You will need to decipher the make rules and run that code generation yourself, I imagine.

How to build Android without the phone application?

i'm trying to get android running on a gumstix overo system.
since i'm not planning to use the final "product" as a phone, i asked my self if it is possible to exclude applications like the phone/dialer-app from the kernel build-process (any config parameter probably?)
Just remove (or comment) these lines:
<project path="packages/apps/Phone" name="platform/packages/apps/Phone" />
<project path="packages/apps/VoiceDialer" name="platform/packages/apps/VoiceDialer" />
(and others if needed) from the platform manifest (default.xml) :
https://android.googlesource.com/platform/manifest/+/master/default.xml
Removing the app declarations in the repo manifest did not work for me, as there are other libraries that reference them that then fail to compile. The build system approach to this problem is to create/modify your product definition makefile to not include the specific apps.
So, for the overo you probably already have a products/overo.mk product file. You can manually set the PRODUCT_PACKAGES variable to which applications you want to ship. You will also want to take a look at the PRODUCT_POLICY variable, as it defines sets of applications for your product type.
It can take some fiddling to get everything to build correctly, due to interdependencies between applications, but the Android build output does a pretty good job of explaining the problems when they arise.

Categories

Resources